# Extension:Math

MediaWiki extensions manual - list
Math

Release status: stable

Implementation Tag
Description Allows to render mathematical formulas between $ ... $ tags
Author(s) Tomasz Wegrzanowski, Brion Vibber and others
Last version 1.0 (2011-04-09)
MediaWiki 1.19+
Database changes yes
Schema registration yes
Parameters
• $wgUseTeX •$wgTexvc
• $wgTexvcBackgroundColor •$wgMathCheckFiles
• $wgMathPath •$wgMathDirectory
• $wgMathFileBackend •$wgUseMathJax
• $wgMathJaxUrl Check usage and version matrix Bugs: list open list all report The Math extension provides support for rendering mathematical formulas on-wiki 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 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 1. Compile texvc (Don't have permission to compile code in your environment? read the see also section below) 2. Add the following to LocalSettings.php: require_once("$IP/extensions/Math/Math.php");
3. you might also have to add
$wgTexvc = '/your/path/to/texvc'; 4. Run update.php as you would if you were upgrading: php /your/path/to/mediawiki/maintenance/update.php 5. Installation can now be verified through your wiki's Special:Version page ## 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 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".
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

## MathJax

From 1.19/1.20, the Math extension supports rendering via MathJax, a client-side JavaScript library for parsing latex or mathml code and producing in-browser 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 high-resolution 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$wgUseMathJax = true; // enabeling MathJax as rendering option
$wgDefaultUserOptions['math'] = MW_MATH_MATHJAX; // setting MathJax as default rendering option (optional)$wgMathJaxUrl = 'http://example.com/path/to/MathJax/MathJax.js?config=TeX-AMS_HTML'; // specifying the path to local MathJax in case MathJax's CDN should not be used (optional)

## LaTeXML

A convenient option to render LaTeX is to use the LaTeXML web service. This service converts LaTeX to high quality MathML. If you check out the LaTeXML branch of this extension you can use the first alpha version of this service. Just go to your math extension and type

git checkout LaTeXML

To change the LaTeXML service address adjust the settings of $wgLaTeXMLUrl= "http://latexml.mathweb.org/convert"; A short guide to install LaTeXML on your own server can be found here: Install LaTeXML ## See also • 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 $x$.
• Another alternative is to use LaTeX with Google Chart Tools.