Extension:MathJax

Updated
The extension has been updated for MediaWiki 1.18.2 and MathJax 2.0 and has undergone a complete rewrite. Changes include:
 * Per page control of options (e.g., turn on or off parsing of ).
 * New  tag to exclude certain parts from MathJax.
 * Consistent numbering among different formula environments.
 * Numbering can be turned on and off.
 * Use of content delivery network for MathJax, this means you don't have to install MathJax yourself.
 * Zero configuration for default use (except including MathJax in your configuration).

Important note:
 * The configuration (if you would need it) has changed, see the section further down this page.

What can this extension do for you?
Extension:MathJax enables MathJax (http://www.mathjax.org/), a Javascript library, for typesetting TeX and LaTeX formulae in MediaWiki inside math environments. The following math environments are defined for inline style math: And the following math environments are defined for display style math: MathJax produces nice and scalable mathematics, see their website (http://www.mathjax.org/) for a demonstration. This extension also enables the usage of  and   tags with automatic formula numbering. If needed you can still hand label by using.
 * (can be turned off, even per page),
 * and
 * (can be turned off, even per page),
 * and
 * and

Usage
This extension allows for typical LaTeX math integration. For example: (Which comes from a preprint of Jon M. Borwein, et. al. Some arithmetic properties of short random walk integrals.)

This renders as http://www.cs.kuleuven.be/~dirkn/Extension_MathJax/MathJaxExample.png.

Difference with the default + math handling
Note: The default Extension:Math now also includes experimental support for MathJax but only through the  tags.

In standard mode math handling on mediawiki is done using  from Extension:Math. But, if you but still want to render math, then this extension could be a solution for you.
 * don't want to use  because you
 * want scalable nicer mathematics,
 * the comfort of a real LaTeX like environment,
 * find having LaTeX on your server too inconvenient (or a security risk); or
 * can't use
 * as you have trouble configuring and compiling, or
 * can't easily write png files (because of ) or
 * for some other reason,

The main reason to use this extension is to have a natural way to write mathematics on your wiki without having to type  when you can just type.

Note that you could as well load the MathJax JavaScript library by customizing your WM skin or account, but there is still one major advantage of this extension over such a method: E.g., writing $$ \sum f(x) = F(x) + g(x) $$ does what you want it to do using this extension, but not when using a customization method as the whitespace at the beginning of line 2 will make WM introduce a  tag and thus break the formula environment for MathJax.
 * this extension allows you to use as much white space in your formula as you want.

Installation instructions
To install Extension:MathJax you need to put the  code on your server as well as a MathJax Javascript configuration file:. These files should be placed in a directory called  from the root of your MediaWiki installation. To enable the extension you then need to modify your  MediaWiki configuration file: add the following to LocalSettings.php: require_once("$IP/extensions/MathJax/MathJax.php"); The MathJax library will be used over the CDN, so you do not have to install MathJax yourself. (You still could: read the documentation in .)

It doesn't matter if you have  set to   or  ; Extension:MathJax will take over rendering of the standard   math tags.

Further configuration can be done by adding after the  line any of these configuration options: MathJax_Parser::$MathJaxJS = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; MathJax_Parser::$MathJaxConfig = "$IP/extensions/MathJax/mwMathJaxConfig.js"; MathJax_Parser::$disabled = false; MathJax_Parser::$do_number = true; MathJax_Parser::$do_dollar = true; MathJax_Parser::$do_dollardollar = true; Above the default values are listed. They have the following effect:
 * : Use MathJax content delivery network (CDN) (the easy default) or set the URL to your own installation.
 * : The MathJax configuration file to use, defaults to mwMathJaxConfig.js in extension directory. (This is a file you need to download and save as well.)
 * : Disable the extension unless marked on the page to enable it by putting  somewhere. You can disable by putting.
 * : Turn on or off numbering and  linking by this extension, also by   and.
 * : Turn on or off processing of inline math delimited by dollar sign: . Also by   and.
 * : Turn on or off processing of display math delimited by double dollar sign: . Also by   and.

Possible issues

 * The following will render incorrectly  as   is executed in between the   and   hooks. A solution is to add a space as in.


 * This anonymous comment was placed here: "Our wiki had a page the had a dollar sign " $ " in it. When we installed MathJax the page refused to load.  I suspect that we need one of the parser functions in localsettings, but that should be clearly laid out in the install instructions. Please put comments and queries on the  Discussion page of this extension and be more specific." There is not enough information in this message to guess at what the problem is. My guess is that you either installed the extension with an older version of MediaWiki or with an older version of PHP installed. Please enable the extension once more and then check both the php error log and the webserver error log to see what is going on.

Changelog

 * 0.5 (20101116)
 * Initial public release.


 * 0.5.1 (20101201)
 * Modifications to allow integration with Extension:Semantic_MediaWiki.
 * Compatability code for Parser::MARKER_SUFFIX added.


 * 0.5.2 (20110203)
 * Kind of revert move away from the markers used by MW as it does no really matter which ones we use (so no need for the SMW fix from 0.5.1 anymore).
 * Allowed \label and \tag at the same time as one would expect.
 * Added clickable links for the formula references, this currently assumes the used label or tag is a valid XHTML id.


 * 0.5.2b (20110215)
 * Removed redundant comma's in the MathJax configuration hub file to please IE...


 * 0.6 (20120418)
 * Updates for MediaWiki 1.18 (tested with 1.18.2) and MathJax 2.0, amonst others incorporating a patch from EvanChou (thanks!) and the CDN modification of Evan. This is mainly a maintenance update to get the extension back on track for 1.18.2.


 * 0.7 (20120422)
 * Complete rewrite, $ and $$ can now be turned on and off, much better protection and detection, numbering is consistent among different environments, no global variables anymore (everything is now in one class), new tag, magic words to turn on and off features: __MATHJAX__ and __NOMATHJAX__ , __MATHJAX_NUMBER__ and __MATHJAX_NONUMBER__ , __MATHJAX_DOLLAR__ and __MATHJAX_NODOLLAR__ , and __MATHJAX_DOLLARDOLLAR__ and __MATHJAX_NODOLLARDOLLAR__.