This site is supported by donations to The OEIS Foundation.

MathJax

From OeisWiki
Jump to: navigation, search


This article page is a stub, please help by expanding it.


See also: MathJax server side (no need to download MathJax.js thus reducing page load times drastically) (since the MathJax rendering is done on the server, there is no Flash Of Unstyled Content issue).


MathJax[1] is an open-source JavaScript display engine for mathematics which takes either MathML, LaTeX or ASCIIMathML[2] as input to get either HTML+CSS, MathML or SVG as output, that works in all modern browsers (with JavaScript enabled, that is). (It is the successor of jsMath.)

MathJax grew out of the popular jsMath project, an earlier Ajax-based math rendering system developed by Davide Cervone in 2004. It requires no setup on the part of the user (no plugins to download or software to install). MathJax uses [scalable] web-based fonts. With MathJax, mathematics is text-based (equations can be searchable) rather than image-based. Note that the TeX input processor implements only the math-mode macros of TeX and LaTeX, not the text-mode macros. MathJax v2.0-beta introduced SVG rendering. MathJax can be installed on various web server platforms, including MediaWiki, Drupal, WordPress, and Joomla.

Support for TeX / LaTeX and MathML in MathJax:

  • The support for TeX and LaTeX in MathJax consists of two parts: the tex2jax.js preprocessor, and the TeX input processor (converts into MathJax’s internal format, which is essentially MathML).
  • The support for MathML in MathJax consists of two parts: the mml2jax.js preprocessor, and the TeX input processor (converts into MathJax’s internal format, which is essentially MathML).

For examples of how nice MathJax's generated HTML-CSS (from the LaTeX code) looks in your browser (unfortunately, after an admittedly horribly long Flash Of Unstyled Content), see... how... long...

Note that after the page has been viewed once, the rendered page is saved in your browser cache so you don't experience the Flash Of Unstyled Content again. (To experience it again, you must clear your browser cache, or at least remove the web page from it.)

The user may choose among three rendering options from the contextual menu "Math Settings > Math Renderer"

STIX fonts

MathJax uses STIX fonts,[3] which are [scalable] Web fonts under royalty-free license. (Web fonts allow Web designers to use fonts that are not installed on the viewer's computer.)

MediaWiki support

From Extension:Math#MathJaxMediaWiki.org.

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
<syntaxhighlight lang="php" enclose="div">
$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)
</syntaxhighlight>

OEIS Wiki is currently using MediaWiki version 1.30.0 (See Special:Version). (OEIS Wiki does not currently use Extension:SyntaxHighlight GeSHi)

MathJax server side

No need for JavaScript to be activated on the browser.
No need to download MathJax.js thus reducing page load times drastically.
Since the MathJax rendering is done on the server, there is no Flash Of Unstyled Content issue.

To support Mathjax server side we need to use MathJax-node. Mathjax-node has been incorporated into Mathoid which is part of MediaWiki’s Math Extension.

  • MathJax-node:[4] This repository contains a library that provides an API to call MathJax from Node.js programs. The API converts individual math expressions (in any of MathJax’s input formats) into HTML (with CSS), SVG, or MathML code.
  • Mathoid:[5][6] Uses MathJax and PhantomJS (for server-side JavaScript) to create SVGs and MathML server side with minimum overhead.

See also

  • Typesetting systems
  • {{Math}} OEIS Wiki utility template (an experimental template to render [very simple] mathematical expressions in HTML/CSS, using helper templates instead of JavaScript)

Notes

External links