Extension:Math
Math Release status: stable 


Implementation  Tag  
Description  Allows to render mathematical formulas between <math> ... </math> tags 

Author(s)  Tomasz Wegrzanowski, Brion Vibber and others  
Latest version  1.2.0 (20140328)  
Latest preview version  2.0  
MediaWiki  1.19+  
Database changes  Yes  
Tables  math  
License  GNU General Public License 2.0  
Download  






Translate the Math extension if possible 

Check usage and version matrix; code metrics  
Bugs: list open list all report 
The Math extension provides support for rendering mathematical formulas onwiki via texvc and other backends. It was a part of the core MediaWiki software until MediaWiki 1.18, r85706. See also the related bug #14202 on Bugzilla.
Contents
Download[edit  edit source]
You can download the extension directly from the MediaWiki source code repository (browse code). You can get:
 One of the extensions tags
Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag
 Go to the tags list
 Click the name of the tag you want to download
 Click "snapshot"
 The latest version of one of the extensions branches
Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.
 Go to the branches list
 Click the branch name
 Click "snapshot"
 A snapshot made during the release of a MediaWiki version.
This might be unstable and is not guaranteed to work with the associated MediaWiki version.
After you've got the code, save it into the extensions/Math directory of your wiki.
If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:
cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Math.git
Installation[edit  edit source]
 Download and extract the files in a directory called
Math
in yourextensions/
folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository.  Add the following code at the bottom of your LocalSettings.php:
require_once( "$IP/extensions/Math/Math.php" ); // Set this if you don't use MediaWiki Math's texvc: $wgTexvc = '/your/path/to/texvc'; // Be sure to have a math directory with writing // permission and that these two variables are set or // default to that directory: $wgMathDirectory = 'filesystem/path/of/the/math/directory'; $wgMathPath = 'URL/path/of/the/math/directory';
 Run the update script which will automatically create the necessary database tables that this extension needs.
 Compile texvccheck or set
$wgMathDisableTexFilter = true;
 Compile texvc if you want to use the PNG images. If you don't have permission on your server to compile code in the environment, read the see also section below.
 Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.
Configuration settings[edit  edit source]
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". 
MathJax[edit  edit source]
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. For now, users will have to opt in to MathJax on their preferences. In the future we hope to make it the default rendering mode.
 Settings (Math 1.1 // MW 1.19  1.22)
$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 (Math 2.0 // MW 1.23+)
// or
$wgMathValidModes = array( MW_MATH_MATHJAX ); // setting MathJax as only rendering option (optional)
$wgUseMathJax = true; // enabeling MathJax as rendering option
$wgDefaultUserOptions['math'] = MW_MATH_MATHJAX; // setting MathJax as default rendering option (optional)
LaTeXML[edit  edit source]
A convenient option to render LaTeX is to use the LaTeXML web service. This service converts LaTeX to high quality MathML.
You can enable the LaTeXML rendering option with the following settings
 Settings
$wgUseLaTeXML = true;
// Set LaTeXML as default rendering option (optional)
$wgDefaultUserOptions['math'] = MW_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
The installation of Math is simplified to:
 Download and extract the files in a directory called
Math
in yourextensions/
folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository.  Add the following code at the bottom of your LocalSettings.php:
require_once( "$IP/extensions/Math/Math.php" ); $wgUseLaTeXML = true; $wgUseMathJax = true; $wgDefaultUserOptions['math'] = MW_MATH_LATEXML;
 Run the update script which will automatically create the necessary database tables that this extension needs.
 Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.
Purging pages that contain equations[edit  edit source]
Specifying the URLparameter action=purge does not force the math equation to rerender the math tags. If a complete rerendering of the math tags is desired the URLparameter action=purge&mathpurge=true has to be passed. Be aware that this might cause side effects with other pages since the math extension uses the hash of the input TeXinputstring as the caching key. e.g. if you would force the rerending with mathpurge option for a page containing the equation $E=mc^2$, the new rendering result would be used on all other pages containing $E=mc^2$ after the individual page caches are invalidated.
Error reporting[edit  edit source]
If something is wrong with the math extension you can report that at bugzilla. In addition you should check how your problem relates to the automated unit tests that are generated from the page mediawikiwiki:Extension:Math/CoverageTest.
MathJax errors[edit  edit source]
MathJax has more bugs that latex. So please check it it's an MediaWiki Bug or a MathJax problem. If it's a MathJax problem that has been fixed you might consider to port the change to MediaWiki version of MathJax. Therefore a development environment is required. Just cherrypick the change from MathJax and apply it to the modules/MathJax folder in the Math extension. Afterwards you can submit your change for review.
See also[edit  edit source]
 Enabling TeX
 en:Wikipedia:texvc  description of texvc
 If you are on a shared host and cannot compile texvc or a local mimetex server, you can follow the instructions here to get math up and running. This scenario is typical of shared hosting environments.
 An alternative is to use Extension:MathJax which enables more common LaTeX formula delimiters, e.g., you can write $x$ instead of <math>x</math>.
 Another alternative is to use LaTeX with Google Chart Tools.
 Extension:Math/Roadmap roadmap for further development
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. 
 Extensions with unknown license
 Stable extensions
 Tag extensions
 GPL licensed extensions
 Extensions in Wikimedia version control
 ParserFirstCallInit extensions
 GetPreferences extensions
 LoadExtensionSchemaUpdates extensions
 ParserTestTables extensions
 ParserTestParser extensions
 UnitTestsList extensions
 All extensions
 Extensions used on Wikimedia
 Math extensions
 TeX