Extension:Math/advancedSettings

Other languages:
English • ‎español • ‎polski • ‎português do Brasil • ‎日本語

The Math extension provides support for rendering mathematical formulas on-wiki via texvc and other backends. An overview of what can currently be done with this extension is found at the English Wikipedia's documentation.

Warning Warning: Information about configurating the extension in older MediaWiki versions is removed from this page. It may be found in the page history.

ConfigurationEdit

Server-side rendering with MathoidEdit

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.

Server-side rendering with LaTeXMLEdit

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.

List of all configuration settingsEdit

The following variables can be defined in LocalSettings.php after calling require_once "$IP/extensions/Math/Math.php";:

On the individual pages for these settings, it says deprecated in 1.18, since this extension was split from core mediawiki in that version. If you've installed the extension, these settings apply regardless
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 double-check 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 short-circuit 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=TeX-AMS-MML_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 HTTP-Request 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 $wgMathLaTeXMLUrl: [1]

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 $wgMathLaTeXMLUrl = array ( 'http://latexml.example.com/convert', 'http://latexml2.example.com/convert');

$wgMathLaTeXMLTimeout 240 The timeout for the HTTP-Request 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 modeEdit

By default, MathML is only exposed to accessibility tools. However, you can force visual rendering with the following style:

 .mwe-math-mathml-a11y {
     clip: auto !important;
     overflow: visible !important;
     position: static !important;
     width: auto !important;
     height: auto !important;
     opacity: 1 !important;
 }
 .mwe-math-fallback-image-inline, .mwe-math-fallback-image-display {
     display: none !important;
 }

You can then easily change the style of MathML formulas e.g. to set the math font:

 .mw-body, mtext {
     font-family: Latin Modern Roman;
 }
 math {
     font-family: Latin Modern Math;
 }
.mw-body, 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!