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 | ||
Last version | 1.0 (2011-04-09) | ||
MediaWiki | 1.19+ | ||
Database changes | yes | ||
Schema registration | yes | ||
License | GNU General Public License 2.0 | ||
Download | |||
|
|||
|
|||
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 [edit]
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]
- Compile texvc (Don't have permission to compile code in your environment? read the see also section below)
- Add the following to LocalSettings.php:
require_once("$IP/extensions/Math/Math.php");
- you might also have to add
$wgTexvc = '/your/path/to/texvc';
- Run update.php as you would if you were upgrading:
php /your/path/to/mediawiki/maintenance/update.php
- Installation can now be verified through your wiki's Special:Version page
Configuration settings [edit]
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". |
MathJax [edit]
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
$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 [edit]
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 [edit]
- 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 high-traffic 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. |