Extension:Math/advancedSettings
The Math extension provides support for rendering mathematical formulas onwiki via texvc and other backends. An overview of what can currently be done with this extension is found at the English Wikipedia's documentation.
Contents
Installing texvc
IMPORTANT: The content of this page is outdated. The Math extension doesn't include a Makefile, therefore the "make" command is not going to work. If you have checked or updated this page and found the content to be suitable, please remove this notice. 
The following steps are required for serverside LaTeX to PNG conversion.
About texvc
The TeX validator and converter texvc takes formulae and produces formatted output in HTML, MathML, and PNG images. Input data is parsed and scrutinized for safety.
On a shared host with limited command line access, (e.g. under jailshell) compiling with all the dependencies won't be possible. As a workaround compiling texvc will have to be done offline. Use uname a
to identify the OS of the shared host, and install the same offline. This can be done via a USB boot drive, live CD, virtual machine on a desktop PC or whichever you prefer. Then for example in Ubuntu, all dependencies can be installed using:
sudo aptget install buildessential dvipng ocaml texlivefontsrecommended texlivelanggreek texlivelatexrecommended
Get the Math extension and make texvc etc.:
wget https://extdist.wmflabs.org/dist/extensions/MathREL1_235d564a6.tar.gz
tar zxvf MathREL1_235d564a6.tar.gz
rm MathREL1_235d564a6.tar.gz
cd Math
make
rm math/*.o
cd ..
tar pczf texvcfiles.tar.gz Math/ # archive the files for easy upload
Upload the texvcfiles.tar.gz
archive to the host and extract the required files into the $IP/extensions/Math folder.
To test texvc is working (see texvc usage), e.g.:
texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso88591 "rgb 1.0 1.0 1.0"
On a host with full shell access
Compile texvc and texvccheck:
cd $IP/extensions/Math/
# install the dependencies listed in the Math subfolder README file e.g.:
sudo aptget install buildessential ocaml
make
On a (virtual) private server
Installing texvc
IMPORTANT: The content of this page is outdated. The package is missing, has been obsoleted, or is only available from another source. If you have checked or updated this page and found the content to be suitable, please remove this notice. 
In some Linux distributions texvc and texvccheck come already built in the MediaWiki Math packages.
See Comparison of extensions in distributions.
For example in Debian or Ubuntu to install it and any other packages on which it depends:
sudo aptget install mediawikimath
(MediaWiki, Math, texvc and texvccheck ) or
sudo aptget install mediawikimathtexvc
(just texvc)
Configuration
Please make sure to put the configuration after require_once "$IP/extensions/Math/Math.php";
, otherwise the MW_MATH_XXX constants will be undefined.
Clientside rendering with MathJax
From 1.19/1.20, the Math extension supports rendering via MathJax, a clientside JavaScript library for parsing latex or mathml code and producing inbrowser representation using the browser's native support for HTML+CSS, or MathML, or SVG.
This can render math expressions more sharply (using subpixel antialiasing) and larger (scaling up for zoomed view, printing, or highresolution screens).
Set $wgUseMathJax to enable MathJax rendering mode; it is still somewhat experimental. Users will have a check box on their preferences that will enable MathJax, or set MathJax to the default mode as shown below.
 Settings (MW 1.19  1.22)
$wgUseMathJax = true; // enabling MathJax as rendering option
$wgDefaultUserOptions['math'] = MW_MATH_MATHJAX; // setting MathJax as default rendering option (optional)
/**
* The default parser for MathJax is 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeXAMS_HTML'
* If you don't want to or can't use the default and your run your own locally
* replace the below url with something like:
* $wgMathJaxUrl = '/mathjax/MathJax.js?config=TeXAMSMML_HTMLorMML';
*/
$wgMathJaxUrl = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeXAMS_HTML';
 Settings (MW 1.23  1.25)
$wgMathValidModes[] = MW_MATH_MATHJAX; // Define MathJax as one of the valid math rendering modes
$wgUseMathJax = true; // Enable MathJax as a math rendering option for users to pick
$wgDefaultUserOptions['math'] = MW_MATH_MATHJAX; // Set MathJax as the default rendering option for all users (optional)
$wgDefaultUserOptions['mathJax'] = true; // Enable the MathJax preference option by default (optional)
$wgMathDisableTexFilter = true; // or compile "texvccheck"
See also How to modify the MathJax contextual menu.
 Forcing MathJax as the only rendering option (MW 1.23+)
If you have a wiki where MathJax is the only available rendering mode, and wish to force it to be enabled, add the following to LocalSettings.php instead of the above:
$wgMathValidModes = array(MW_MATH_MATHJAX); // Define MathJax as the only valid math rendering mode
$wgUseMathJax = true; // Enable MathJax
$wgDefaultUserOptions['math'] = MW_MATH_MATHJAX; // Set MathJax as the default rendering option
$wgDefaultUserOptions['mathJax'] = true; // Enable the MathJax checkbox option
$wgHiddenPrefs[] = 'math'; // Hide math preference
$wgHiddenPrefs[] = 'mathJax'; // Hide MathJax checkbox
$wgMathDisableTexFilter = true; // or compile "texvccheck"
This will switch on MathJax by default for all anonymous users and those without preferences saved for the Math extension. Note that if registered users had an alternate rendering mode selected, it will be necessary for them to open Preferences > Appearance and click Save for the new forced setting to take effect. Articles should advise users about the requirement for JavaScript to be enabled in order to see formulae (e.g. through a template for articles including TeX formulae).
Serverside rendering with Mathoid
Beginning from MW 1.23+ you can use a Mathoid server that uses MathJax to convert texvc input on the server side to MathML+SVG rendering. Mathoid is the rendering mode that is going to be used on future Wikipedia. For that the following settings are recommended:
// ensure 'mathml'; is added to the $wgMathValidModes array;
$wgMathValidModes[] = 'mathml';
// Set Mathoid as default rendering option;
$wgDefaultUserOptions['math'] = 'mathml';
Check out Mathoid to find instructions how to run your own Mathoid server. After enabling the MathML rendering mode you have to run the database update script again to create the required table.
Serverside rendering with LaTeXML
A convenient option to render LaTeX is to use the LaTeXML web service. This service converts LaTeX to high quality MathML.
 Settings (MW 1.22) most or all of the 1.23+ settings also work
// Enable LaTeXML as rendering option
$wgUseLaTeXML = true; // this became an unused setting around 1.23
 Settings (MW 1.23+)
$wgMathValidModes[] = 'latexml'; // adding LaTeXML as rendering option
// Set LaTeXML as default rendering option;
$wgDefaultUserOptions['math'] = 'latexml';
// Specify the path to your LaTeXML instance that converts the \TeX commands to MathML (optional)
$wgLaTeXMLUrl = 'http://example.com/';
A short guide to install LaTeXML on your own server can be found here: Install LaTeXML
After enabling the LaTeXML rendering mode you have to run the database update script again to create the required table.
Serverside rendering with LaTeX
To use your local webserver to convert the texvc input to PNG images via a local LaTeX installation and OCAML based translation from texvc to LaTeX you have to install texvc; see above for how to do that.
Settings in LocalSettings.php
should refer to the latex
rendering engine:
// ensure 'latex'; is added to the $wgMathValidModes array;
$wgMathValidModes[] = 'latex';
// Set texvc as default rendering option;
$wgDefaultUserOptions['math'] = 'latex';
List of all configuration settings
The following variables can be defined in LocalSettings.php after calling require_once "$IP/extensions/Math/Math.php";
:
Setting name  Default value  Description 

$wgUseTeX  true

Backward compatibility global; no longer does anything. 
$wgTexvc  dirname( __FILE__ ) . '/math/texvc'

Location of the texvc binary 
$wgTexvcBackgroundColor  'transparent'

Texvc background color; use LaTeX color format as used in \special function. For transparent background use value 'Transparent' for alpha transparency or 'transparent' for binary transparency. 
$wgMathCheckFiles  true

Normally when generating math images, we doublecheck that the directories we want to write to exist, and that files that have been generated still exist when we need to bring them up again.
This lets us give useful error messages in case of permission problems, and automatically rebuild images that have been lost. On a big site with heavy NFS traffic this can be slow and flaky, so sometimes we want to shortcircuit it by setting this to false. 
$wgMathPath  false

The URL path of the math directory. Defaults to "{$wgUploadPath }/math". 
$wgMathDirectory  false

The filesystem path of the math directory. Defaults to "{$wgUploadDirectory }/math". 
$wgUseMathJax  false

Enables MathJax as rendering option. 
$wgMathJaxUrl  '$IP/extensions/MathJax/MathJax.js?config=TeXAMSMML_HTMLorMML'

The url to MathJax if not using the default default parser at http://cdn.mathjax.org/. 
$wgMathValidModes  array( 'png', 'source' )

Defines the mode allowed on the server. 
$wgMathMathMLUrl  'http://mathoid.testme.wmflabs.org'

The url of the mathoid server. 
$wgMathMathMLTimeout  20

The timeout for the HTTPRequest sent to the MathML to render an equation, in seconds. 
$wgMathLaTeXMLUrl  'http://gw125.iu.xsede.org:8888'

Use of LaTeXML.
If you want or need to run your own server, follow these installation
instructions and override If you expect heavy load you can specify multiple servers. In that case one
server is randomly chosen for each rendering process. Specify the list of
servers in an array e.g 
$wgMathLaTeXMLTimeout  240

The timeout for the HTTPRequest sent to the LaTeXML to render an equation, in seconds. 
$wgMathDefaultLaTeXMLSetting  array(
'format' => 'xhtml',
'whatsin' => 'math',
'whatsout' => 'math',
'pmml',
'cmml',
'nodefaultresources',
'preload' => array(
'LaTeX.pool',
'article.cls',
'amsmath.sty',
'amsthm.sty',
'amstext.sty',
'amssymb.sty',
'eucal.sty',
'[dvipsnames]xcolor.sty',
'url.sty',
'hyperref.sty',
'[ids]latexml.sty',
'texvc' ),
)

Setting for the LaTeXML renderer for details. 
$wgMathDisableTexFilter  false

Option to disable the tex filter. If set to true any LaTeX expression is parsed this can be a potential security risk. If set to false only a subset of the TeX commands is allowed. See Help:Displaying a formula for details. 
$wgMathEnableExperimentalInputFormats  false

Enables experimental MathML and AsciiMath input format support 
CSS for the MathML with SVG fallback mode
By default, MathML is only exposed to accessibility tools. However, you can force visual rendering with the following style:
.mwemathmathmla11y {
clip: auto !important;
overflow: visible !important;
position: static !important;
width: auto !important;
height: auto !important;
opacity: 1 !important;
}
.mwemathfallbackimageinline, .mwemathfallbackimagedisplay {
display: none !important;
}
You can then easily change the style of MathML formulas e.g. to set the math font:
.mwbody, mtext {
fontfamily: Latin Modern Roman;
}
math {
fontfamily: Latin Modern Math;
}
.mwbody,
is added to get the same font appearance for the entire article text. If you do not want to change your main font, then leave this out. Do not forget to remove the comma, as well!This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such hightraffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. 