MathJax Documentation¶
MathJax is an opensource JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers, with builtin support for assistive technology like screen readers.
Version 3.0 of MathJax is a complete rewrite of MathJax from the ground up, and its usage and configuration is significantly different from that of MathJax version 2. Use the green menu at the bottom of the sidebar on the left to access the version 2 documentation if you need it.
What is MathJax?¶
MathJax is an opensource JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers. It was designed with the goal of consolidating the recent advances in web technologies into a single, definitive, mathontheweb platform supporting the major browsers and operating systems, including those on mobile devices. It requires no setup on the part of the user (no plugins to download or software to install), so the page author can write web documents that include mathematics and be confident that users will be able to view it naturally and easily. One simply includes MathJax and some mathematics in a web page, and MathJax does the rest.
MathJax uses webbased fonts to produce highquality typesetting that scales and prints at full resolution, unlike mathematics included as bitmapped images. With MathJax, mathematics is textbased rather than imagebased, and so it is available for search engines, meaning that your equations can be searchable, just like the text of your pages. MathJax allows page authors to write formulas using TeX and LaTeX notation, MathML (a World Wide Web Consortium standard for representing mathematics in XML format), or AsciiMath notation. MathJax can generate output in several formats, including HTML with CSS styling, or scalable vector graphics (SVG) images.
MathJax includes the ability to generate speakable text versions of your mathematical expressions that can be used with screen readers, providing accessibility for the visually impaired. The assistive support in MathJax also includes an interactive expression explorer that helps these users to “walk through” an expression one piece at a time, rather than having to listen to a complex expression all at once, and the ability to “collapse” portions of the expressions to allow a more simplified expression to be read, and only expanded if more detail is desired.
MathJax is modular, so it can load components only when necessary, and can be extended to include new capabilities as needed. MathJax is highly configurable, allowing authors to customize it for the special requirements of their web sites. Unlike earlier versions of MathJax, version 3 can be packaged into a single file, or included as part of larger bundles for those sites that manage their javascript assets in that way.
Finally, MathJax has a rich application programming interface (API)
that can be used to make the mathematics on your web pages interactive
and dynamic. Version 3 has been rewritten in ES6 using Typescript (a
version of javascript that includes typechecking and the ability to
transpile to ES5). It was designed to be used as easily on a server
(as part of a node.js
application) as it is in a browser. This makes
preprocessing of web pages containing mathematics much easier than
with version 2, so web sites can perform all the math processing once
up front, rather than having the browser do it each time the page is
viewed.
Accessibility Features¶
MathJax’s mission is to provide the best tools for mathematics on the web. Naturally, this means for everyone and thus accessibility is an important concern for us.
MathJax User Interface¶
The MathJax user interface currently consists of the MathJax Menu and the various MathJax messages, such as syntax error messages from the TeX input processor.
The user interface for version 2 was localized to over 20 languages and many more partial localizations thanks to the fantastic support of the community at TranslateWiki.net. Localization is not yet available in version 3, but is on the roadmap for a future version.
The MathJax Menu follows WCAG 2.0 guidelines. Each MathJax fragment is included in the tab order; the menu can be triggered via the space or menu key; and navigation in the menu is possible using the arrow keys.
MathJax Accessibility Extensions¶
The MathJax Accessibility extensions provide several tools and features that enable universal rendering of mathematics on the web. They enhance rendering both visually and aurally. In particular:
 An innovative responsive rendering of mathematical content through collapsing and exploration of subexpressions.
 An aural rendering tool providing onthefly speechtext for mathematical content and its subexpressions using various rule sets.
 Tactile rendering tool enabling Nemeth Braille output on a connecte Braille displays.
 An exploration tool, allowing for meaningful exploration of mathematical content including multiple highlighting features, magnification and synchronized aural rendering.
The Accessibility Extensions support the widest selection of browsers, operating systems, and assistive technologies as they only require the use of wellsupported web standards such as WAIARIA, in particular labels and live regions.
The Accessibility Extensions can be enabled using the MathJax
Contextual Menu (rightclick on any typeset expression), and are
loaded automatically when enabled. The contextual menu code is
included in all the combined MathJax components, such as texchtml
and mmlsvg
. If you are making a custom configuration, you can
include ui/menu
to enable the contextual menu, or you can include
any of the a11y extensions explicitly.
See the Accessibility Extensions Options section for details about how to configure the extensions.
Screen Reader Support¶
Some screen readers support MathML, MathJax’s internal format.
Screenreaders like ChromeVox, JAWS (on IE), and TextHelp support
MathJax directly (most only version 2); other screenreaders are
supported by the assistivemml
extension as of version 3.0.1.
The assistivemml
extension embeds visually hidden MathML alongside
MathJax’s visual rendering while hiding the visual rendering from
assistive technology (AT) such as screenreaders. This allows most
MathMLenabled screenreaders to read out the underlying
mathematics. It’s important to note that Presentation MathML is
usually not expressive enough to voice the mathematics properly in all
circumstances, which is why screenreaders have to rely on heuristics
to analyze the MathML semantically.
The quality of MathML support in screenreaders varies greatly, with different levels of MathML feature support, different speech rule sets, and different voicing technologies.
The expected result for MathJax given the current state of technology is roughly the following:
 The visuallyhidden MathML is read out correctly by AT (i.e., not
just the character strings but, e.g.,
<mfrac>
leads to “fraction”; this will vary with the MathML support of the screenreader).  The visual rendering is not read out by AT
 The MathJax Menu triggers AT to say “clickable” before each math element.
 This allows keyboard users to enter the MathJax Menu via space or menu key.
 The visually hidden MathML does not get an outline (usually placed
at an odd location due to the target of the outline being visually
hidden).
 except in iOS VoiceOver, where this allows the user to hook into VoiceOver’s exploration features.
More Information¶
Accessibility Extension¶
MathJax offers accessibility support via its own builtin extension that provides a choice of support options as well as a high degree of personalization. The extension can be activated either via the context menu, which itself is fully accessible, or by default using configuration options. Similarly its various features and options are best selected via the MathJax Menu or programmatically using the accessibility options. We discuss the different features of the accessibility tool at the hand of the context menu, roughly in the order in which they appear.
Most features of the Accessibility extensions are based on technology provided by the Speech Rule Engine. For some more details and information please also see there.
MathJax’s supports the widest selection of browsers, operating systems, and assistive technologies as they only require the use of wellsupported web standards such as WAIARIA, in particular labels and live regions.
Interactive Exploration¶
The main feature is an interactive exploration mode that allows a reader to traverse and explore subexpressions stepbystep. The explorer is activated in the context menu by checking the Activate item in the Accessibility submenu.
Once a math expression is focused, the explorer can be started by pressing the Enter key. The cursor keys then allow traversal of the expression.
Keyboard Explorer Commands¶
The keyboard explorer is used to interact with a mathematical expression using keyboard commands. Interaction allows a reader to traverse an expression in a mathematical meaningful way, examining subexpressions and diving into details as they see fit.
The keyboard explorer supports multiple types of output: Speech and Braille output for the subexpression that is explored, magnification of that subexpression, and synchronised highlighting with the navigation.
Navigation can be started when a MathJax expression is focused and quit at any time during the exploration. When navigation is restarted, the application will continue where the user has left off within the expression.
Overview of key bindings¶
Essential Keys¶
Enter  Activate explorer. Requires math expression to have the focus. 
Escape  Leave exploration mode. 
Down  Explore next lower level of the formula by moving down in the subexpression tree. Exploration will start at the leftmost subexpression on the level. 
Up  Move up the subexpression tree. 
Right  Navigate the expression horizontally by moving to the next subexpression on the current level. 
Left  Navigate the expression horizontally by moving to the previous subexpression on the current level. 
An earcon is played as indicator that the boundary of an expression has been reached in either direction.
Advanced Options¶
Tab  Repeat previous speechtext or announcement. 
Space  Get positional information; i.e., the current level in the subexpression tree as well as collapsibility/expandability of the current subexpression. 
Enter  Collapse or expand expression under cursor, if possible. Speechtext is regenerated to match. 
Home  Navigate directly to topmost level of expression. 
X  Summarise the expression under cursor, without collapsing it. 
Z  Give detailed description of expression under cursor, without expanding it. 
V  Start new virtual cursor from the current position. 
P  Go to last position or previous virtual cursor 
U  Undo all virtual cursors; i.e.; go to position where first virtual cursor was started. 
>  Switch rule sets between MathSpeak and ClearSpeak, if both are available for the current locale. 
<  Cycle styles or preferences for the currently active rule sets. 
Special Notes¶
Note
Depending on the implementation quality of the particular browser/screenreader/OS combination (especially Chrome and IE), users might have to disable screenreader reading modes (e.g., “browse mode” in NVDA, “virtual cursor” in JAWS) before being able to launch the MathJax explorer application.
During traversal, focused subexpressions are highlighted and optionally magnified. In addition, an aural rendering is pushed to a screen reader, if one is available, and a tactile rendering can be read on a Braille display, if one is connected.
Speech & Braille Support¶
Both aural and tactile rendering can be controlled via the options in the Speech submenu. Speech Output and Braille Output, respectively, control whether or not speech or Braille output is generated. If speech is generated, it is by default also displayed in Speech Subtitles, which can be switched off and hidden. Braille on the other hand is by default hidden but can be displayed by switching on the Braille Subtitles.
Speech is generally generated with respect to the currently chosen locale (if it is available). In addition, there are a number of different rule sets that can be chosen for translating math to text, where each can have a number of different preferences for how a particular expression is spoken. By default, MathJax uses the MathSpeak rule set in Verbose mode; however, the menu allows this to be changed to either the ClearSpeak or ChromeVox. Each rule set has several different preference settings; three in the case of MathSpeak, for example, which primarily influence the length of produced text. ClearSpeak on the other hand has a large number of preferences that allow very finetuned control over how different types of expressions are spoken. The MathJax menu allows a smart choice of preferences by only displaying the preferences that are currently relevant for the subexpression that is currently explored. The Select Preferences option opens a selection box for all possible ClearSpeak preference choices.
Some ruleset and preference settings can also be controlled by keyboard commands. This allows the user to have the same expression read in different variants without having to leave the exploration mode. The > key switches rule sets between MathSpeak and ClearSpeak if both are available for the current locale. The < key cycles preferences for the currently active rule set. For ClearSpeak rules, preference cycling depends on the type of the currently explored subexpression, similar to smart selection of menu entries.
The speech language can be adjusted in the Language submenu in the Speech options. MathJax currently only supports speech in English, French, German, and Spanish. The only available Braille output is Nemeth. We are hoping to add more in the future.
In addition to voicing expressions, the explorer allows for queries on subexpression, such as getting positional information with respect to the context, as well as summaries of the subexpression currently explored.
Abstraction¶
In addition to textual summaries of expressions, MathJax offers the possibility to abstract certain subexpressions so that the entire subexpression is visually replaced by a placeholder symbol and interactive traversal treats it as a single element. This allows the reader to abstract away details and to better observe the overall structure of a formula.
Abstraction can be triggered either via mouse click on a collapsible expression or via pressing the Enter key during keyboard exploration. Expressions that can be abstracted can also be discovered using some of the highlighting features.
Highlight¶
During interactive exploration, the subexpression that is explorered is automatically highlighted, by default with a blue background color. The highlighting can be customized by changing Background or Foreground colors in in the Highlight submenu of the MathJax contextual menu. In addition, the opacity of both Background and Foreground can be adjusted by two slider bars underneath the respective submenus.
The Highlight submenu also provides a choice of highlighters for marking collapsible subexpressions: The Flame highligher permanently colors collapsible subexpressions while successively darkening the background for nested collapsible expressions. The Hover highlighter colors each collapsible subexpression only when hovering over it with the mouse pointer.
A final highlighting feature is Tree Coloring, in which expressions are visually distinguished by giving neighbouring symbols different, ideally contrasting foreground colors.
Magnification¶
During exploration, the accessibility extension can optionally magnify the subexpression that is currently explored. The zoomed version of the expression is overlayed on the original one when traversing the formula. For keyboard exploration, this can be switched on in the Magnification submenu by selecting the Keyboard option.
A similar effect can be achieved by exploring an expression with the mouse. When using the Mouse option in the Magnification submenu, the subexpression over which the mouse pointer hovers is zoomed.
The zoom factor of the magnification can also be adjusted. The values available in the context menu are 200%, 300%, 400%, and 500%.
Semantic Info¶
The Semantic Info submenu contains a number of options that allow the reader to see the semantic classifications MathJax applies to a particular subexpression, by hovering over it with the mouse pointer. The choices here are
 Type is an immutable property of an expression that is independent of its particular position in a formula. Note, however that types can change depending on the subject area of a document.
 Role is dependent on the context of a subexpression in the overall expression.
 Prefix
is information pertaining to the position of a
subexpression. Examples are
'exponent'
,'radicand'
, etc. These would also be spoken during interactive exploration.
For more details on all of these concepts, see also the documentation of the Speech Rule Engine.
Legacy Assistive Support in v2¶
Interactions between screen readers and MathJax are delicate and vary from browser to broswer, operating system to operating system, and screen reader to screen reader. The following information was gathered over time for version 2 of MathJax and various broser/operatingsystem/screenreader combinations. The information is several years old, and my no longer be completely accurate, as features in browsers and screen readers change regularly. Because this inforamtion changes regularly with updates to browsers and screen readers, we are unable to maintin a table like this for version 3.
Support Matrix (AssistiveMML.js)¶
Below is a summary of results for MathML enabled screenreaders and the legacy AssistiveMML extension, based on tests as well as user reports.
Screenreader  Browser  OS  Usable?  Bugs 

ChromeVox  Chrome  any  +1  no bugs 
NVDA  any  WinXP  DNA  MathPlayer 4 does not support WinXP 
NVDA  Chrome  any  DNA  Chrome issues prevent MathML support by NVDA 
NVDA  Firefox  Win7  +1  no bugs 
NVDA  Firefox  Win8.1  +1  no bugs 
NVDA  Firefox  Win10  +1  no bugs 
NVDA  MS Edge  Win10  DNA  Edge issues prevent MathML support by NVDA 
NVDA  IE11  Win8.1  +1  no bugs 
NVDA  IE10  Win7  +1  no bugs 
NVDA  IE9  Win7  +1  no bugs 
JAWS  any  WinXP  DNA  JAWS 15 was the last version to support Windows XP but MathML support in JAWS starts with JAWS 16 
JAWS  Chrome  any  DNA  JAWS only supports IE and Firefox 
JAWS  Firefox  Win8.1  +1  no bugs 
JAWS  Firefox  Win7  +1  no bugs 
JAWS  Firefox  Win10  +1  no bugs 
JAWS  MS Edge  Win10  DNA  JAWS only supports IE and Firefox 
JAWS  IE11  Win8.1  +1  no bugs 
JAWS  IE10  Win7  +1  no bugs 
JAWS  IE9  Win7  +1  no bugs 
VoiceOver  Safari  OSX  +1  see notes below 
VoiceOver  Chrome  OSX  DNA  Chrome and VoiceOver issues prevent MathML support in this combination. 
VoiceOver  Firefox  OSX  DNA  Chrome and Firefox issues prevent MathML support in this combination. 
Orca  Firefox  Ubuntu 15.10  +1  no bugs 
Orca  Web  Ubuntu 15.10  DNA  Chrome issues prevent MathML support by ORCA 
Orca  Chrome(ium)  Ubuntu 15.10  DNA  Chrome issues prevent MathML support by ORCA 
Notes on Apple VoiceOver¶
 VoiceOver on OSX
 Safari. The visuallyhidden MathML is read out and gets an outline. Visual rendering is ignored correctly. VoiceOver somtimes drops parts of the equation due to its partial MathML support.
 Chrome. The visuallyhidden MathML is detected but VoiceOver does not read it correctly (only e.g., “4 items detected; math”; this seems like a VO bug); an outline is added. Visual rendering is ignored correctly.
 Firefox. The visuallyhidden MathML is only read as a string of contained characters; an outline is added. Visual rendering is ignored correctly.
 VoiceOver on iOS
 The “slide two fingers from top to read screen” method will read the visuallyhidden MathML. Visual rendering is ignored correctly.
 Manual exploration.
 Exploration by swiping left/right will read the visuallyhidden MathML. Visual rendering is ignored correctly.
 Tapping on an equation does not work due to the visuallyhidden MathML being placed in a 1px box.
Notes on MathPlayer 4 and Internet Explorer 11¶
Design Science suggests that you always use IE’s Enterprise mode for MathPlayer in IE11, see their documentation. However, it seems that this is only required for MathPlayer’s visual rendering to work and this additionally requires the MathPlayer BrowserHelperAddon to be active in IE.
Unfortunately, the MathPlayer BrowserHelperAddon can lead to crashes. E.g., if you switch MathJax’s output to the NativeMML output, MathPlayer will crash IE11; you’ll have to clear the MathJax cookie to reset things. Also, in a plain MathML sample (without MathJax), clicking on the MathPlayer rendering will crash IE11.
Using IE’s Enterprise mode should work with NVDA and the AssistiveMML extension but they don’t seem to work with NVDA and plain MathML pages.
We suggest you do not switch on IE’s Enterprise mode on pages using MathJax and we also have to strongly suggest that you not use the BrowserHelperAddon with MathJax on IE11.
Writing Mathematics for MathJax¶
Putting mathematics in a web page¶
To put mathematics in your web page, you can use TeX and LaTeX notation, MathML notation, AsciiMath notation, or a combination of all three within the same page; the MathJax configuration tells MathJax which you want to use, and how you plan to indicate the mathematics when you are using TeX/LaTeX or AsciiMath notation. These three formats are described in more detail below.
TeX and LaTeX input¶
Mathematics that is written in TeX or LaTeX format is indicated using math delimiters that surround the mathematics, telling MathJax what part of your page represents mathematics and what is normal text. There are two types of equations: ones that occur within a paragraph (inline mathematics), and larger equations that appear separated from the rest of the text on lines by themselves (displayed mathematics).
The default math delimiters are $$...$$
and \[...\]
for
displayed mathematics, and \(...\)
for inline mathematics. Note
in particular that the $...$
inline delimiters are not used
by default. That is because dollar signs appear too often in
nonmathematical settings, which could cause some text to be treated
as mathematics unexpectedly. For example, with singledollar
delimiters, “… the cost is $2.50 for the first one, and $2.00 for
each additional one …” would cause the phrase “2.50 for the first
one, and” to be treated as mathematics since it falls between dollar
signs. See the section on TeX and LaTeX Math Delimiters for more information on using dollar signs as
delimiters.
Here is a complete sample page containing TeX mathematics (see the MathJax Web Demos Repository for more).
<!DOCTYPE html>
<html>
<head>
<title>MathJax TeX Test Page</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/texchtml.js">
</script>
</head>
<body>
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {b \pm \sqrt{b^24ac} \over 2a}.$$
</body>
</html>
Since the TeX notation is part of the text of the page, there are some caveats that you must keep in mind when you enter your mathematics. In particular, you need to be careful about the use of lessthan signs, since those are what the browser uses to indicate the start of a tag in HTML. Putting a space on both sides of the lessthan sign should be sufficient, but see TeX and LaTeX support for more details.
If you are using MathJax within a blog, wiki, or other content management system, the markup language used by that system may interfere with the TeX notation used by MathJax. For example, if your blog uses Markdown notation for authoring your pages, the underscores used by TeX to indicate subscripts may be confused with the use of underscores by Markdown to indicate italics, and the two uses may prevent your mathematics from being displayed. See TeX and LaTeX support for some suggestions about how to deal with the problem.
There are a number of extensions for the TeX input processor that are
loaded by combined components that include the TeX input format (e.g.,
texchtml.js
), and others that are loaded automatically when
needed. See TeX and LaTeX Extensions for
details on TeX extensions that are available.
MathML input¶
For mathematics written in MathML notation, you mark your mathematics
using standard <math>
tags, where <math display="block">
represents displayed mathematics and <math display="inline">
or
just <math>
represents inline mathematics.
MathML notation will work with MathJax in HTML files, not just XHTML
files, even in older browsers and that the web page need not be served
with any special MIMEtype. Note, however, that in HTML (as opposed to
XHTML), you should not include a namespace prefix for your <math>
tags; for example, you should not use <m:math>
except in an XHTML file
where you have tied the m
namespace to the MathML DTD by adding the
xmlns:m="http://www.w3.org/1998/Math/MathML"
attribute to your file’s
<html>
tag.
In order to make your MathML work in the widest range of situations,
it is recommended that you include the
xmlns="http://www.w3.org/1998/Math/MathML"
attribute on all
<math>
tags in your document (and this is preferred to the use of
a namespace prefix like m:
above, since those are deprecated in
HTML5), although this is not strictly required.
Here is a complete sample page containing MathML mathematics (see the MathJax Web Demos Repository for more).
<!DOCTYPE html>
<html>
<head>
<title>MathJax MathML Test Page</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/mmlchtml.js">
</script>
</head>
<body>
<p>
When
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mi>a</mi><mo>≠</mo><mn>0</mn>
</math>,
there are two solutions to
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mi>a</mi><msup><mi>x</mi><mn>2</mn></msup>
<mo>+</mo> <mi>b</mi><mi>x</mi>
<mo>+</mo> <mi>c</mi> <mo>=</mo> <mn>0</mn>
</math>
and they are
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>x</mi> <mo>=</mo>
<mrow>
<mfrac>
<mrow>
<mo>−</mo>
<mi>b</mi>
<mo>±</mo>
<msqrt>
<msup><mi>b</mi><mn>2</mn></msup>
<mo>−</mo>
<mn>4</mn><mi>a</mi><mi>c</mi>
</msqrt>
</mrow>
<mrow>
<mn>2</mn><mi>a</mi>
</mrow>
</mfrac>
</mrow>
<mtext>.</mtext>
</math>
</p>
</body>
</html>
When entering MathML notation in an HTML page (rather than an XHTML page), you should not use selfclosing tags, as these are not part of HTML, but should use explicit open and close tags for all your math elements. For example, you should use
<mspace width="5pt"></mspace>
rather than <mspace width="5pt" />
in an HTML document. If you
use the selfclosing form, some browsers will not build the math tree
properly, and MathJax will receive a damaged math structure, which
will not be rendered as the original notation would have been.
Typically, this will cause parts of your expression to not be
displayed. Unfortunately, there is nothing MathJax can do about that,
since the browser has incorrectly interpreted the tags long before
MathJax has a chance to work with them.
See the MathML page for more on MathJax’s MathML support.
AsciiMath input¶
MathJax v2.0 introduced a new input format, AsciiMath notation, by incorporating ASCIIMathML. This input processor has not been fully ported to MathJax version 3 yet, but there is a version of it that uses the legacy version 2 code to patch it into MathJax version 3. None of the combined components currently include it, so you would need to specify it explicitly in your MathJax configuration in order to use it. See the AsciiMath page for more details.
By default, you mark mathematical expressions written in AsciiMath by
surrounding them in “backticks”, i.e., `...`
.
Here is a complete sample page containing AsciiMath notation:
<!DOCTYPE html>
<html>
<head>
<title>MathJax AsciiMath Test Page</title>
<script>
MathJax = {
loader: {load: ['input/asciimath', 'output/chtml']}
}
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js">
</script>
<body>
<p>When `a != 0`, there are two solutions to `ax^2 + bx + c = 0` and
they are</p>
<p style="textalign:center">
`x = (b + sqrt(b^24ac))/(2a) .`
</p>
</body>
</html>
See the AsciiMath support page for more on MathJax’s AsciiMath support and how to configure it.
Putting Math in Javascript Strings¶
If your are using javascript to process mathematics, and need to put a
TeX or LaTeX expression in a string literal, you need to be aware that
javascript uses the backslash (\
) as a special character in
strings. Since TeX uses the backslash to indicate a macro name, you
often need backslashes in your javascript strings. In order to
achieve this, you must double all the backslashes that you want to
have as part of your javascript string. For example,
var math = '\\frac{1}{\\sqrt{x^2 + 1}}';
This can be particularly confusing when you are using the LaTeX macro \, which must both be doubled, as \. So you would do
var array = '\\begin{array}{cc} a & b \\\\ c & d \\end{array}';
to produce an array with two rows.
The MathJax Community¶
If you are an active MathJax user, you may wish to become involved in the wider community of MathJax users. The MathJax project maintains forums where users can ask questions about how to use MathJax, make suggestions about future features for MathJax, and present their own solutions to problems that they have faced. There is also a bugtracking system where you can report errors that you have found with MathJax in your environment.
Mailing Lists¶
If you need help using MathJax or you have solutions you want to share, please post to the MathJax Users Google Group. We try hard to answer questions quickly, and users are welcome to help with that as well. Also, users can post code snippets showing how they have used MathJax, so it may be a good place to find the examples you are looking for.
If you want to discuss MathJax development, please use the MathJax Dev Google Group. We made this group to discuss anything beyond what an enduser might be interested in, so if you have any suggestions or questions about MathJax performance, technology, or design, feel free to submit it to the group.
The community is only as good as the users who participate, so if you have something to offer, please take time to make a post on one of our groups.
Issue tracking¶
Found a bug or want to suggest an improvement? Post it to our issue tracker. We monitor the tracker closely, and work hard to respond to problems quickly.
Before you create a new issue, however, please search the issues to see if it has already been reported. You could also be using an outdated version of MathJax, so be sure to upgrade your copy to verify that the problem persists in the latest version.
See the section on Reporting Issues for more detailed instructions.
Documentation¶
The source for this documentation can be found on github. You can file bug reports on the documentation’s bug tracker and actively contribute to the public documentation wiki.
“Powered by MathJax”¶
If you are using MathJax and want to show your support, please consider using our “Powered by MathJax” badge.
Reporting Issues¶
If you come across a problem with MathJax, please report it so that the development team and other users are aware and can look into it. It is important that you report your problem following the steps outlined here because this will help us to rapidly establish the nature of the problem and work towards a solution effectively.
To report a problem, please follow these steps:
 Have you cleared your browser cache, quit your browser, and restarted it? If not, please do so first and check if the problem persists. These instructions tell you how to clear your cache on the major browsers.
 Have you turned off other extensions and plugins in your browser, and restarted it?
 Have a look at the math rendering examples on www.mathjax.org to see if you experience problems there as well. This might help you to determine the nature of your problem.
 If possible, check whether the problem has been solved in the latest MathJax release.
 Search through the MathJax User Group and the MathJax issue tracker to see if anyone else has come across the problem before.
 Found a real and new problem? Please report it to the MathJax issue
tracker including the
following information:
 A detailed description of the problem. What exactly is not working as you expected? What do you see?
 The MathJax version you are working with, your operating system, and full browser information including all version information.
 If at all possible, a pointer to a webpage that is publicly available and exhibits the problem. This makes sure that we can reproduce the problem and test possible solutions. You can create minimal examples using such tools as jsfiddle, jsbin, codepen, or codesandbox.
Getting Started with MathJax Components¶
MathJax allows you to include mathematics in your web pages, either using LaTeX, MathML, or AsciiMath notation, and the mathematics will be processed using JavaScript to produce HTML or SVG for viewing in any modern browser.
MathJax Components¶
To make using MathJax easier in web pages, the various pieces that make up MathJax have been packaged into separate files called “components”. For example, there is a component for MathML input, and one for SVG output, and the various TeX extensions are packaged as separate components. You can mix and match the various components to customize MathJax to suit your particular needs (this is described in detail in the section on Configuring MathJax below); the individual component files that you specify are loaded when MathJax starts up.
There are also components that combine several others into one larger
file that loads everything you need to run MathJax all at once. These
represent some of the standard combinations of input and output
formats, and you will probably find one of these that suits your
needs. You can configure the various
components in order to customize how they run, even when they are
loaded as part of a combined component. For example, you can set the
delimiters to be used for inline and displayed math for the TeX input
component whether the TeX component was loaded individually, or as
part of the texchtml
component.
It is even possible for you to create your own components or custom builds of MathJax, or incorporate the MathJax components into larger files that contain other assets your website might need (see the section on Making a Custom Build of MathJax for more details).
Ways of Accessing MathJax¶
There are two ways to access MathJax for inclusion in web pages: link
to a content delivery network (CDN) like cdn.jsdelivr.net
to obtain a
copy of MathJax, or download and install a copy of MathJax on your own
server (for network access) or hard disk (for local use without a
network connection). The first method is described below, while the
second is discussed in the section on Hosting Your Own Copy of MathJax.
This page gives the quickest and easiest ways to get MathJax up and running on your web site, but you may want to read the details in the linked sections in order to customize the setup for your pages.
Using MathJax from a Content Delivery Network (CDN)¶
The easiest way to use MathJax is to link directly to a public installation available through a Content Distribution Network (CDN). When you use a CDN, there is no need to install MathJax yourself, and you can begin using MathJax right away. The CDN will automatically arrange for your readers to download MathJax files from a fast, nearby server.
To use MathJax from a CDN, you need to do three things:
 Include a MathJax configuration in your page (this may be optional in some cases).
 Link to MathJax in the web pages that are to include mathematics.
 Put mathematics into your web pages so that MathJax can display it.
There are many free CDN services that provide copies of MathJax. Most of them require you to specify a particular version of MathJax to load, but some provide “rolling releases”, i.e., links that update to the latest available version upon release (note that we also provide a means of obtaining the latest version automatically, described below).
 jsdelivr.com [latest or specific version] (recommended)
 unpkg.com [latest or specific version]
 cdnjs.com
 raw.githack.com
 gitcdn.xyz
 cdn.statically.io
To jump start using jsdelivr
, you accomplish the first two steps by putting
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/texmmlchtml.js">
</script>
into the <head>
block of your document. (It can also go in the
<body>
if necessary, but the head is to be preferred.) This will
load the latest 3.x.x version of MathJax from the distributed server,
configure it to recognize mathematics in both TeX and MathML notation,
and ask it to generate its output using HTML with CSS (the CommonHTML
output format) to display the mathematics.
Warning
The texmmlchtml.js
file includes all the pieces needed for
MathJax to process these two input formats and produce this
output format. There are several other choices with different
input/output combinations, and and you can even configure MathJax to
load components individually.
We list this file here because it will get you started quickly with MathJax without having to worry too much about configurations; but since it is one of the most general of the combined component files, it is also one of the largest, so you might want to consider a smaller one that is more tailored to your needs. See the section on Configuring and Loading MathJax for more details on how this is done, and on The MathJax Components for information about the components themselves.
If you use the code snippet given above, you will not need to change
the URL whenever MathJax is updated and the version changes, because
jsdelivr
offers the mathjax@3
notation for obtaining the
texmmlchtml.js
file from the latest version (3.x.x) available on
the CDN.
Getting the Latest Version¶
Although jsdelivr
provides a means of getting the latest version
automatically, as described above, not all CDNs have a mechanism for
that. For such CDNs, MathJax provides a latest.js
file that can
be used to obtain the latest (3.x.x) version of MathJax. For example,
cdnjs
doesn’t have a mechanism for getting the latest 3.x.x
version automatically, so you can use
<script type="text/javascript" id="MathJaxscript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.0.0/es5/latest?texmmlchtml.js">
</script>
to obtain the latest (3.x.x) version of the texmmlchtml
component from cdnjs
; even though you have started by asking for
version 3.0.0, the latest.js
script will switch to the latest
3.x.x version automatically.
Getting a Specific Version¶
It is also possible to always use a specific version, regardless of the current version of MathJax. To do this, simply give the full version number in the URL; for example:
<script id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3.0.0/es5/texmmlchtml.js">
</script>
will always load version 3.0.0 of the texmmlchtml.js
combined
component file.
Other CDNs have slightly different formats for how to specify the
version number. For example, cdnjs
uses the following:
<script type="text/javascript" id="MathJaxscript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.0.0/es5/texmmlchtml.js">
</script>
to get the same file.
Browser Compatibility¶
MathJax supports all modern browsers (Chrome, Safari, Firefox, Edge), and most mobile browsers. Include the polyfill library in order to support earlier browser versions (see their browser support page for details). In particular, to allow MathJax version 3 to work with IE11, include the line
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
before the script that loads MathJax.
Configuring MathJax¶
The combined component files, like texmmlchtml.js
, include default
settings for the various options available in MathJax. You may need
to adjust those to suit your needs. For example, the TeX input
component does not enable single dollar signs as delimiters for
inline mathematics because single dollar signs appear frequently in
normal text, e.g. “The price is $50 for the first one, and $40 for
each additional one”, and it would be confusing the have “50 for the
first one, and” be typeset as mathematics.
If you wish to enable single dollar signs as inline math delimiters,
you need to tell MathJax that by providing an explicit MathJax
configuration. That is accomplished by using a <script>
tag to
set the MathJax
global variable to hold a configuration for
MathJax and placing that script before the one that loads the MathJax
component file that you are using. For example
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
}
};
</script>
<script id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/texchtml.js">
</script>
configures MathJax’s TeX input component to use $...$
and
\(...\)
as delimiters for inlinemath (this enabling single
dollar signs as math delimiters), and then loads the texchtml.js
component for TeX input and CommonHTML output.
There are many options that can be set in this way. See the section on Configuring and Loading MathJax for more details, and on Configuring MathJax for information on the available options for the various components.
Putting Mathematics in a Web Page¶
Once MathJax is configured and loaded, it will look through your web page for mathematics for it to process. There are three available formats for that mathematics: TeX/LaTeX, MathML, and AsciiMath. The TeX/LaTeX and AsciiMath formats are plain text formats that use special delimiter characters to separate the mathematics from the rest of the text of your document, while the MathML format is an XML format that uses “tags” (similar to HTML tags) to represent the mathematics. TeX and AsciiMath are often written by hand, but MathML usually is generated by mathematical software or specialized editors.
See the section on Writing Mathematics for MathJax for more details about how to enter mathematics in these three formats.
Note that once MathJax has processed the page, it will not run again without you explicitly telling it to. For example, if you add new mathematics to the page after MathJax has already run, that math will not be processed by MathJax until you request that to happen. See the section on MathJax in Dynamic Content for details of how to do that.
Where to Go from Here?¶
If you have followed the instructions above, you should now have MathJax installed and configured on your web server, and you should be able to use it to write web pages that include mathematics. At this point, you can start making pages that contain mathematical content!
You could also read more about the details of how to customize MathJax.
You can also check out the MathJax examples for illustrations of using MathJax.
If you are working on dynamic pages that include mathematics, you might want to read about the MathJax Application Programming Interface (its API), so you know how to include mathematics in your interactive pages.
Finally, if you have questions or comments, or want to help support MathJax, you could visit the MathJax community forums or the MathJax bug tracker.
Configuring and Loading MathJax¶
The configuration, loading, and startup processes for MathJax version
3 are different from those of version 2 in a number of ways. Where
version 2 had several different methods for configuring MathJax,
version 3 streamlines the process and has only one, as described
below. In version 2, you always loaded MathJax.js
, and added a
config=...
parameter to provide a combined configuration file, but
in version 3 you load one of several different files, depending on
your needs (so you can avoid multiple file transfers, and also use
MathJax synchronously, which was not possible in version 2).
If you use one of the combined component files in version 3, like
mmlchtml
, you may not need to do any configuration at all.
Configuring MathJax¶
To configure MathJax, you use a global object named MathJax that
contains configuration data for the various components of MathJax.
For example, to configure the TeX input component to use single dollar
signs as inline math delimiters (in addition to the usual \(...\)
delimiters) and the SVG output component to use a global font cache
for all expressions on the page, you would use
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
svg: {
fontCache: 'global'
}
};
The sections below describe the different places you could put such a configuration. For information on the options that you can set for each of the components, see the Configuring MathJax pages.
Configuration Using an InLine Script¶
The easiest way to configure MathJax is to place the MathJax
object in a <script>
tag just before the script that loads MathJax
itself. For example:
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
svg: {
fontCache: 'global'
}
};
</script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/texsvg.js">
</script>
This will configure the TeX input component to use single dollar
signs as inline math delimiters, and the SVG output component to use
a global font cache (rather than a separate cache for each expression
on the page), and then loads the latest version of the texsvg
component file from the jsdelivr
CDN. This will typeset any TeX
mathematics on the page, producing SVG versions of the expressions.
Using a Local File for Configuration¶
If you are using the same MathJax configuration over multiple pages,
you may find it convenient to store your configuration in a separate
JavaScript file that you load into the page. For example, you could
create a file called mathjaxconfig.js
that contains
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
svg: {
fontCache: 'global'
}
};
and then use
<script src="mathjaxconfig.js" defer></script>
<script type="text/javascript" id="MathJaxscript" defer
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/texsvg.js">
</script>
to first load your configuration file, and then load the texsvg
component from the jsdelivr
CDN.
Note that here we use the defer
attribute on both scripts so that
they will execute in order, but still not block the rest of the page
while the files are being downloaded to the browser. If the async
attribute were used, there is no guarantee that the configuration
would run first, and so you could get instances where MathJax doesn’t
get properly configured, and they would seem to occur randomly.
Configuring and Loading in One Script¶
It is possible to have the MathJax configuration file also load
MathJax as well, which would be another way to handle the problem of
synchronizing the two scripts described above. For example, you could
make the file loadmathjax.js
containing
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
svg: {
fontCache: 'global'
}
};
(function () {
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/texsvg.js';
script.async = true;
document.head.appendChild(script);
})();
and then simply link to that file via
<script src="loadmathjax.js" async></script>
This script can be async
because it doesn’t have to synchronize
with any other script. This will allow it to run as soon as it loads
(since it is small, there is little cost to that), meaning the script
to load MathJax itself will be inserted as soon as possible, so that
MathJax can begin downloading as early as possible. (If this script
were loaded with defer
, it would not run until the page was ready,
so the script to load MathJax would not be inserted until then, and
you would have to wait for MathJax to be downloaded before it could
run.)
Converting Your v2 Configuration to v3¶
Because the version 3 configuration options are somewhat different
from their version 2 counterparts, we provide an automated
configuration conversion tool
to help you move from version 2 to version 3. Simply paste your
current MathJax.Hub.Config()
call into the converter, press
Convert
and you should get the equivalent version 3 configuration,
and comments about any options that could not be translated to version
3 (some options are not yet implements, others no longer make sense in
version 3). See the instructions on the linked page for more details.
Loading MathJax¶
Once you have configured MathJax, you then load the MathJax component
file that you want to use. Most often, this will mean you load a
combined component that loads everything you need to run MathJax with
a particular input and output format. For example, the texsvg
component would allow you to process TeX input and produce SVG output.
To do so, use a script like the following
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/texsvg.js">
</script>
to get the latest (3.x.x) version of the texsvg
component in ES5
format (the only one currently available) from the jsdelivr
CDN.
This takes advantage of the feature of jsdeliver
that allows you
to get the latest version using the mathjax@3
notation. For a
specific version, you would use
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3.0.0/es5/texsvg.js">
</script>
to always get the 3.0.0 version of the texsvg
component.
Other CDNs have slightly different formats for how to specify the
version number. For example, cdnjs
uses the following:
<script type="text/javascript" id="MathJaxscript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.0.0/es5/texsvg.js">
</script>
Some CDNs don’t provide a means of getting the lastest version
automatically. For these, MathJax provides a latest.js
file that
will do that for you. For example, cdnjs
doesn’t have a mechanism
for getting the latest 3.x.x version automtically. If you want to do
that using cdnjs
, then use
<script type="text/javascript" id="MathJaxscript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.0.0/es5/latest?texsvg.js">
</script>
to obtain the latest (3.x.x) version of the texsvg
component.
See The MathJax Components for a list of the various components you can choose and descriptions of their contents. See the list of CDNs for the URLs for a number of CDNs that serve MathJax.
Note that the script that loads the MathJax component file should follow the script that configures MathJax (otherwise MathJax will not know what configuration you need). If you use one of the combined component files in version 3, you may not need to do any configuration at all.
Loading Components Individually¶
If none of the combined component files suits your needs, you can
specify the individual components you want by setting the load
array in the loader
section of your MathJax configuration and
loading the startup
component.
For example
<script>
MathJax = {
loader: {
load: ['input/texbase', 'output/svg', 'ui/menu', '[tex]/require']
},
tex: {
packages: ['base', 'require']
}
};
</script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3.0.0/es5/startup.js">
</script>
would cause the base TeX input, the SVG output, the contextual menu
code, and the TeX \require
macro extension components to be loaded
(and would tell TeX to use the require
extension in addition to the
base TeX macros). In this way, you can load exactly the components
you want. Note, however, that each component will be loaded as a
separate file, so it is better to use a combined component file if
possible.
Loading Additional Components¶
You can use the load
array described in the previous section to
load additional components even if you are using one of the combined
components. For example
<script>
MathJax = {
loader: {
load: ['[tex]/colorv2']
},
tex: {
packages: {'[+]': 'colorv2'},
autoload: {color: []}
}
};
</script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3.0.0/es5/texchtml.js">
</script>
would load the version2compatible \color
macro, inform TeX to
add that to the packages that it already has loaded, and not autoload
the default version 3 color
(the LaTeXcompatible one). This is
done on top of the texchtml
combined configuration file, so the
TeX input and CommonHTML output formats are already included (as are
the contextual menu, and several TeX packages; see
The MathJax Components for details).
Performing Actions During Startup¶
MathJax allows you several ways to hook into the MathJax startup
process so that you can do additional configuration, perform actions
after the initial typesetting, and so on. Because MathJax version 3
uses promises for its synchronization, they are what MathJax
provides in order for you to hook into the startup process. There are
two main hooks that you can set in the startup
block of your
configuration: the ready()
function and the
pageReady()
function.
The ready()
function is what MathJax calls when all the
components of MathJax have been loaded. It builds the internal
structures needed by MathJax, creates functions in the MathJax
object to make typesetting and format conversion easy for you,
performs the initial typesetting call, and sets up a promise for when
that is complete. You can override the ready()
function with
one of your own to override the startup process completely, or to
perform actions before or after the usual initialization. For
example, you could do additional setup before MathJax created the
objects it needs, or you could hook into the typesetting promise to
synchronize other actions with the completion of the initial
typesetting. Examples of these are given below.
The pageReady()
function is performed when MathJax is ready
(all its components are loaded, and the internal objects have been
created), and the page itself is ready (i.e., it is OK to typeset the
page). The default is for pageReady()
to perform the initial
typesetting of the page, but you can override that to perform other
actions instead, such as delaying the initial typesetting while other
content is loaded dynamically, for example. The ready()
function sets up the call to pageReady()
as part of its
default action.
The return value of pageReady()
is a promise that is resolved
when the initial typesetting is finished (it is the return value of
the initial MathJax.typesetPromise()
call). If you override
the pageReady()
method, your function should return a promise
as well. If your function calls
MathJax.startup.defaultPageReady()
, then you should return the
promise that it returns (or a promise obtained from its then()
or catch()
methods). The MathJax.startup.promise
will
resolve when the promise you return is resolved; if you don’t return a
promise, MathJax.startup.promise
will resolve immediately,
which may mean that it resolves too early.
Using these two functions separately or in combination gives you full control over the actions that MathJax takes when it starts up, and allows you to customize MathJax’s startup process to suit your needs. Several examples are given below for common situations.
Performing Actions During Initialization¶
If you want to perform actions after MathJax has loaded all the needed
components, you can set the ready()
function to a function that does
the needed actions, and then calls
MathJax.startup.defaultReady()
to perform the usual
startup process.
Actions coming before the MathJax.startup.defaultReady()
call are run before any initialization has been done. In particular,
this is before any input or output jax are created, so this is where
customization of the MathJax object definitions could be performed.
For example, you could modify the configuration blocks at this point,
or you could create subclasses of the MathJax objects that override
some of their methods to produce custom behavior, and then register
those subclasses with MathJax so they will be used in place of the
originals.
Actions coming after the MathJax.startup.defaultReady()
call are run after initialization is complete. In particular, all the
internal objects used by MathJax (e.g., the input and output jax, the
math document, the DOM adaptor, etc) will have been created, and the
typesetting and conversion methods will have been created in the
MathJax
object. Also the MathJax.startup.promise
value
will hold a promise that is resolved when the initial typesetting is
complete, but note that the typesetting has not yet been performed at
this point.
window.MathJax = {
startup: {
ready: () => {
console.log('MathJax is loaded, but not yet initialized');
MathJax.startup.defaultReady();
console.log('MathJax is initialized, and the initial typeset is queued');
}
}
};
The next section shows how to use the MathJax.startup.promise
to synchronize with the initial typesetting action.
Performing Actions After Typesetting¶
Often, you may need to wait for MathJax to finish typesetting the page
before you perform some action. To accomplish this, you can override
the ready()
function, having it perform the
MathJax.startup.defaultReady()
action, and then use the
MathJax.startup.promise
to queue your actions; these will be
performed after the initial typesetting is complete.
window.MathJax = {
startup: {
ready: () => {
MathJax.startup.defaultReady();
MathJax.startup.promise.then(() => {
console.log('MathJax initial typesetting complete');
});
}
}
};
As an alternative, you can override the pageReady()
function,
and use the promise returned from the
MathJax.startup.defaultPageReady()
function:
window.MathJax = {
startup: {
pageReady: () => {
return MathJax.startup.defaultPageReady().then(() => {
console.log('MathJax initial typesetting complete');
});
}
}
};
Be sure that you return the promise that you obtain from
then()
method, otherwise MathJax.startup.promise
will
resolve before the initial typesetting (and your code) has been
performed.
Configuring MathJax After it is Loaded¶
The global variable MathJax
is used to store the configuration for
MathJax. Once MathJax is loaded, however, MathJax changes the
MathJax
variable to contain the various methods needed to control
MathJax. The initial configuration that you provided is moved to the
MathJax.config
property so that its contents doesn’t conflict
with the new values provides in MathJax
. This occurs when the
MathJax component you have requested is loaded (and before the
ready()
function is called).
Once MathJax has created the objects that it needs (like the input and
output jax), changes to the configuration may not have any effect, as
the configuration values were used during the creation of the objects,
and that is already complete. Most objects make a copy of their
configuration from your original MathJax
object, so changing the
values in MathJax.config
after the objects are created will
not change their configurations. (You can change
MathJax.config
values for objects that haven’t been created
yet, but not for ones that have.)
For some objects, like input and output jax, document handlers, and
math documents, the local copies of the configuration settings are
stored in the options
property of the object, and you may be
able to set the value there. For example,
MathJax.startup.output.options.scale
is the scaling value for
the output, and you can set that at any time to affect any subsequent
typeset calls.
Note that some options are moved to subobjects when the main object
is created. For example, with the TeX input jax, the inlineMath
and similar options are used to create a FindTeX
object that is
stored at MathJax.startup.input[0].findTeX
; but in this case, the
FindTeX
object uses the configuration once when it is created, so
changing MathJax.startup.input[0].findTeX.options
will not affect
it. (There is a getPatterns()
method if the FindTeX
object that could be used to refresh the object if the options are
changed, however.)
If you need to change the configuration for an object whose options
can’t be changed once it is created, then you will need to create a
new version of that object after you change the configuration. For
example, if you change MathJax.config.tex.inlineMath
after
MathJax has started up, that will not affect the TeX input jax, as
described above. In this case, you can call
MathJax.startup.getComponents()
to ask MathJax to recreate all
the internal objects (like MathJax.startup.input
). This will
cause them to be created using the new configuration options. Note,
however, that MathJax will no longer know about any mathematics that
has already been typeset, as that data was stored in the objects that
have been discarded when the new ones are created.
The MathJax Components¶
In order to make it possible to customize what parts of MathJax you include in your web pages, the MathJax code has been broken into individual pieces, called “components”. These are designed to share common code, so that you don’t download the same thing more than once, while still making it possible to only download the parts that you need. There are individual components for the various input and output processors in MathJax, for the various TeX extensions, for the contextual menu, and for other specialized pieces, such as the assistive technology support. These can be mixed and matched in whatever combinations you need.
There are some obvious combinations of components, for example, TeX input together with SVG output, or MathML input with CommonHTML output. MathJax provides a number of these common combinations as complete packages that contain everything you need to run mathjax in your page in a single file, though you can also configure additional extensions to be loaded as well.
Components provide a great deal of flexibility in determining the pieces of MathJax that you use. You can even make your own custom builds of MathJax that package exactly the pieces that you want to use. See Making a Custom Build of MathJax for more details about how to do that.
See the Loading MathJax section for details about how to specify and load MathJax components.
See the Configuring MathJax section for details about how to configure the various MathJax components.
Combined Components¶
Currently there are eight combined components, whose contents are described below:
The combined components include everything needed to run MathJax in your web pages. Each includes at least one input processor, an output processor, the data needed for the MathJax TeX font, the contextual menu code, and the startup component.
Unlike the other components, these combined components should be
loaded directly via a <script> tag, not through the load
array
in your MathJax configuration. So a typical use would be
<script>
MathJax = {
// your configuration here, if needed
};
</script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/texchtml.js">
</script>
to load the texchtml component, for example.
texchtml¶
The texchtml component loads the input/tex component and the output/chtml, along with the contextual menu component, and the startup component.
The input/tex component loads the ams, newcommand,
require, autoload, configmacros, and
noundefined extensions, which means that most other extensions
will be loaded automatically when needed, or you can use the
\require
macro to load them explicitly.
texchtmlfull¶
The texchtmlfull component loads the input/texfull component and the output/chtml, along with the contextual menu component, and the startup component.
The input/texfull component loads the code for all the TeX extensions, and configures TeX to use all but the physics and colorv2 extensions.
texsvg¶
The texsvg component loads the input/tex component and the output/svg, along with the contextual menu component, and the startup component.
The input/tex component loads the ams, newcommand,
require, autoload, configmacros, and
noundefined extensions, which means that most other extensions
will be loaded automatically when needed, or you can use the
\require
macro to load them explicitly.
texsvgfull¶
The texsvgfull component loads the input/texfull component and the output/svg, along with the contextual menu component, and the startup component.
The input/texfull component loads the code for all the TeX extensions, and configures TeX to use all but the physics and colorv2 extensions.
texmmlchtml¶
The texmmlchtml component loads the input/tex and input/mml components and the output/chtml, along with the contextual menu component, and the startup component.
The input/tex component loads the ams, newcommand,
require, autoload, configmacros, and
noundefined extensions, which means that most other extensions
will be loaded automatically when needed, or you can use the
\require
macro to load them explicitly.
texmmlsvg¶
The texmmlsvg component loads the input/tex and input/mml components and the output/svg, along with the contextual menu component, and the startup component.
The input/tex component loads the ams, newcommand,
require, autoload, configmacros, and
noundefined extensions, which means that most other extensions
will be loaded automatically when needed, or you can use the
\require
macro to load them explicitly.
mmlchtml¶
The mmlchtml component loads the input/mml component and the output/chtml, along with the contextual menu component, and the startup component.
mmlsvg¶
The mmlsvg component loads the input/mml component and the output/svg, along with the contextual menu component, and the startup component.
Input Components¶
Currently there are three MathJax input formats, each packaged into its own component.
These are described in more detail below. See the Input Processor Options section for details about configuring these components.
input/tex¶
The TeX input format is packaged in three different ways, depending on which extensions are included in the component. This gives you several possible tradeoffs between file size and feature completeness. See the TeX and LaTeX input section for details about the TeX input processor.
When you include one of the TeX input components, MathJax will define a function to convert TeX strings into the output format that has been loaded. See the Converting a Math String to Other Formats section for details.
input/tex¶
This is the standard TeX input component. It includes the main
TeX/LaTeX input parser, along with the base definitions for the most
common macros and environments. It also includes the ams,
newcommand, require, autoload,
configmacros, and noundefined extensions. The
remaining extensions (other than physics and
colorv2) are loaded automatically when needed, or you can
use \require
to load any of them explicitly. This will cause the
extensions to be loaded dynamically, so if you are calling MathJax’s
typesetting or conversion methods yourself, you should use the
promisebased versions in order to handle that properly.
See the TeX Input Processor Options section for information about configuring this component.
input/texfull¶
This is the most complete TeX input component. It includes the main
TeX/LaTeX input parser, along with all the TeX extensions, and is
configured to enable all of them other than physics and
colorv2. You can add these two to the packages
array
in the tex
section of your MathJax configuration, though you
should remove the color extension if you add the
colorv2 extension, and should remove the braket
extension if you enable the physics package.
See the TeX Input Processor Options section for information about configuring this component.
input/texbase¶
This is a minimal TeX input component. It includes the main TeX/LaTeX
input parser, along with the base definitions for the most common
macros and environments. No other extensions are included, so no
extensions are autoloaded, and you can not use \require
. For this
component, you must explicitly load the extensions you want to use,
and add them to the packages
array.
See the TeX Input Processor Options section for information about configuring this component.
TeX Extension Packages¶
Each of the TeX extensions listed in the The TeX/LaTeX Extension List has its
own component. The name of the component is the name of the extension
preceded by [tex]/
; so the component for the enclose
extension is [tex]/enclose
. You can include any of the extension
components in the load
array of the loader
section of your
MathJax configuration, and add the extension to the packages
array
in the tex
block. For example:
window.MathJax = {
loader: {load: ['[tex]/enclose']},
tex: {
packages: {'[+]', ['enclose']}
}
};
Of course, if you are using one of the packages that includes the autoload extension, then you don’t have to load the extensions explicitly (except for physics and colorv2), as they will be loaded automatically when first used.
In addition, there is a [tex]/allpackages
component that includes
all the packages, and configures the TeX input processors to include
all of them except physics and colorv2. The
input/texbase and [tex]/allpackages components together are
effectively the same as the input/texfull component.
See the TeX Extension Options section for information about configuring the TeX extensions.
input/mml¶
The input/mml component contains the MathML input processor, including the function that identifies MathML within the page. See the MathML input section for details concerning the MathML input processor. When you include the input/mml component, MathJax will define a function to convert serialized MathML strings into the output format that has been loaded. See the Converting a Math String to Other Formats section for details.
 See the MathML Support section for details about MathML output.
 See the MathML Input Processor Options section for information about configuring this component.
input/asciimath¶
The input/asciimath component contains the AsciiMath input processor, including the function that identifies AsciiMath within the page. See AsciiMath input section or details concerning the AsciiMath input processor. When you include the input/asciimath component, MathJax will define a function to convert AsciiMath strings into the output format that has been loaded. See the Converting a Math String to Other Formats section for details.
See the AsciiMath Input Processor Options section for information about configuring this component.
Note
The AsciiMath input jax has not been fully ported to version 3 yet. The AsciiMath component includes legacy MathJax 2 code patched into the MathJax 3 framework. That makes the AsciiMath component larger than usual, and slower than the other input components.
Output Components¶
Currently there are two MathJax output formats, each packaged into its own component.
These are described in more detail below.
Note
The NativeMML output jax from version 2 has not been ported to version 3, and is unlikely to be. See the MathML Support section for details.
output/chtml¶
The output/chtml component includes the CommonHTML output processor. When loaded, it causes data for handling the MathJax TeX font to be loaded as well (via a separate component). Currently, this is the only font available in version 3 (see the MathJax Font Support section for more information). The output/chtml/fonts/tex component holds the font data.
 See the HTML Support section for details on the CommonHTML output processor.
 See the CommonHTML Output Processor Options section for information about configuring this component.
output/svg¶
The output/svg component includes the SVG output processor. When loaded, it causes data for handling the MathJax TeX font to be loaded as well (via a separate component). Currently, this is the only font available in version 3 (see the MathJax Font Support section for more information). The output/svg/fonts/tex component holds the font data.
 See the SVG Support section for details on the SVG output processor.
 See the SVG Output Processor Options section for information about configuring this component.
Accessibility Components¶
Currently, there are three components designed specifically to support assistive technology.
To load one of these components, include the component name in the
load
array of the loader
block of your MathJax
configuration. For example:
<script>
MathJax = {
loader: {
load: ['a11y/semanticenrich']
}
}
</script>
to load the semanticenrich extension.
Note
The autocollapse extension has not yet been converted to version 3, but will be in a future release.
Note
The assistivemenu extension is now part of the standard contextual menu extension, so doesn’t have to be loaded separately.
a11y/semanticenrich¶
The semanticenrich component connects MathJax with the Speech Rule Engine, which allows MathJax to generate speech strings for the mathematics that it processes. These can be attached to the output for use by screen readers, or for use with the a11y/explorer component described below.
See the SemanticEnrich Extension Options section for information about configuring this component.
a11y/complexity¶
The complexity component computes a complexity measure for each element within an expression, and allows complex expressions to “collapse” to make them both shorter, and simpler to read. The collapsed portions can be expanded with a click of the mouse, or by keyboard actions when using the a11y/explorer extension described below.
See the Complexity Extension Options section for information about configuring this component.
a11y/explorer¶
The explorer component allows readers to explore a mathematical expression interactively. When an expression is focused (by tabbing to it, or by clicking on it), a reader can “enter” the expression by pressing shiftspace on the keyboard. The arrow keys then move the reader through the expression (down moves to more detail by selecting the first subexpression of the selected expression, up moves to more complete expressions, while left and right move through the subexpressions at the current level). See the Accessibility Features section for more details about using the expression explorer and its various features.
See the Explorer Extension Options section for information about configuring this component.
a11y/assistivemml¶
The assistivemml component embeds visually hidden MathML alongside MathJax’s visual rendering while hiding the visual rendering from assistive technology (AT) such as screenreaders. This allows most MathMLenabled screenreaders to read out the underlying mathematics. It’s important to note that Presentation MathML is usually not expressive enough to voice the mathematics properly in all circumstances, which is why screenreaders have to rely on heuristics to analyze the MathML semantically. See the Screen Reader Support section for more details about screen reader support via the assistivemml extension.
See the AssisitveMML Extension Options section for information about configuring this component.
Miscellaneous Components¶
There are several miscellaneous components that don’t fit into other categories. These are:
They are described in more detail below.
startup¶
The startup component is the one that you would use if you are not
using a combined component, but are using
the load
array to specify the components you want to load. Like a
combined component, you would load this directly via a <script> tag,
as in
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js">
</script>
This is the component that manages the global MathJax
object.
It is responsible for creating the needed objects (like the input and
output jax), and for adding the typesetting and conversion methods
described in the Typesetting and Converting Mathematics section.
See the Startup Options section for information about configuring this component.
ui/safe¶
The ui/safe component is intended for use in situations where your
readers will be allowed to enter mathematical notation into your pages
themselves, such as a questionandanswer site, or a blog with user
comments. It filters the mathematics on the page to make sure that
certain values within the mathematics are not misused by the reader to
cause problems on your page. For example, the \href
macro
normally could be used to insert javascript:
URLs into the page;
the ui/safe extension can be used to prevent that.
See the Safe Extension Options section for more information on what is filtered and how to control the level of filtering being performed. See Typesetting UserSupplied Content for additional details.
adaptors/liteDOM¶
The adaptors/liteDOM component implements an alternative to the browser DOM that can be used to parse HTML pages outside of a browser. This can be used in Node applications that don’t have access to a browser DOM, or in webworkers that can’t access the document DOM.
core¶
The core component includes the code that is required for all other components, including the base classes for input and output jax, math documents, math items within those documents, DOM adaptors, and so on. This component is loaded automatically when needed, so you don’t usually have to load it yourself. But you can include it if you are creating your own combined component.
loader¶
The loader component contains the code needed to load other components. It is included automatically by the startup component, but if you don’t want the features created by the startup module, you can use the loader component instead to load the MathJax component you need. You can even use it as a general loader for other javascript, if you want.
See the Loader Options section for information about configuring this component.
Typesetting and Converting Mathematics¶
There are two main uses for MathJax:
 Typesetting all the mathematics within a web page, and
 Converting a string containing mathematics into another form.
In version 2, MathJax could perform the first function very well, but it was much harder to do the second. MathJax version 3 makes both easy to do. Both these tasks are described below.
Typesetting Math in a Web Page¶
MathJax makes it easy to typeset all the math in a web page, and in fact it will do this automatically when it is first loaded unless you configure it not to. So this is one of the easiest actions to perform in MathJax; if your page is static, there is nothing to do but load MathJax.
If your page is dynamic, and you may be adding math after the page is
loaded, then you will need to tell MathJax to typeset the mathematics
once it has been inserted into the page. There are two methods for
doing that: MathJax.typeset()
and
MathJax.typesetPromise()
.
The first of these, MathJax.typeset()
, typesets the page, and
does so immediately and synchronously, so when the call finishes, the
page will have been typeset. Note, however, that if the math includes
actions that require additional files to be loaded (e.g., TeX input
that uses require, or that includes autoloaded extensions), then
an error will be thrown. You can use the try/catch
command to
trap this condition.
The second, MathJax.typesetPromise()
, performs the typesetting
asynchronously, and returns a promise that is resolved when the
typesetting is complete. This properly handles loading of external
files, so if you are expecting to process TeX input that can include
require or autoloaded extensions, you should use this form of
typesetting. It can be used with await
as part of a larger
async
function.
Both functions take an optional argument, which is an array of elements whose content should be processed. An element can be either an actual DOM element, or a CSS selector string for an element or collection of elements. Supplying an array of elements will restrict the typesetting to the contents of those elements only.
Handling Asynchronous Typesetting¶
It is generally a bad idea to try to perform multiple asynchronous
typesetting calls simultaneously, so if you are using
MathJax.typesetPromise()
to make several typeset calls, you
should chain them using the promises they return. For example:
MathJax.typesetPromise().then(() => {
// modify the DOM here
MathJax.typesetPromise();
}).catch((err) => console.log(err.message));
This approach can get complicated fast, however, so you may want to maintain a promise that can be used to chain the later typesetting calls. For example,
let promise = Promise.resolve(); // Used to hold chain of typesetting calls
function typeset(code) {
promise = promise.then(() => MathJax.typesetPromise(code()))
.catch((err) => console.log('Typeset failed: ' + err.message));
return promise;
}
Then you can use typeset()
to run code that changes the DOM
and typesets the result. The code()
that you pass it does the
DOM modifications and returns the array of elements to typeset, or
null
to typeset the whole page. E.g.,
typeset(() => {
const math = document.querySelector('#math');
math.innerHTML = '$$\\frac{a}{1a^2}$$';
return [math];
});
would replace the contents of the element with id="math"
with the
specified fraction and have MathJax typeset it (asynchronously).
Because the then()
call returns the result of
MathJax.typesetPromise()
, which is itself a promise, the
then()
will not resolve until that promise is resolved; i.e.,
not until the typesetting is complete. Finally, since the
typeset()
function returns the promise
, you can use
await
in an async
function to wait for the typesetting to
complete:
await typeset(...);
Note that this doesn’t take the initial typesetting that MathJax
performs into account, so you might want to use
MathJax.startup.promise
in place of promise
above.
I.e., simply use
function typeset(code) {
MathJax.startup.promise = MathJax.startup.promise
.then(() => MathJax.typesetPromise(code()))
.catch((err) => console.log('Typeset failed: ' + err.message));
return MathJax.startup.promise;
}
This avoids the need for the global promise
variable, and
makes sure that your typesetting doesn’t occur until the initial
typesetting is complete.
Resetting Automatic Equation Numbering¶
The TeX input jax allows you to automatically number equations. When modifying a page, this can lead to problems as numbered equations may be removed and added; most commonly, duplicate labels lead to issues.
You can reset equation numbering using the command
MathJax.texReset([start])
where start
is the number at which to start equation numbering.
Updating Previously Typeset Content¶
MathJax keeps track of all the math that it has typeset within your
page. This is so that if you change the output renderer (using the
MathJax contextual menu), it can be changed to use the new format, for
example; or if you change the accessibility settings, say to enable
the expression explorer, all the math can be updated to include the
speech strings that it uses. If you modify the page to include new
mathematics and call MathJax.typeset()
or
MathJax.typesetPromise()
, the newly typeset mathematics will be
added to the list of already typeset mathematics, as you would expect.
If you modify the page to remove content that contains typeset
mathematics, you will need to tell MathJax about that so that it knows
the typeset math that you are removing is no longer on the page. You
do this by using the MathJax.typesetClear()
method.
When called with no arguments, MathJax.typesetClear()
tells
MathJax to forget about all the math that has been typeset so far.
Note that the math will remain in the page as typeset math, but
MathJax will no longer know anything about it. For example, that
means that changes to the output renderer or accessibility settings
will not affect any of the math that was typeset previously.
If you remove math from only a portion of the page, you can call
MathJax.typesetClear()
passing it an array of container
elements that have been (or will be) removed, and MathJax will forget
about the math that is within those containers, while remembering the
rest of the math on the page. For example, if you have an element
with id="hasmath"
that you have previously typeset, and you are
planning to replace the contents of this element with new content
(stored in a variable new_html
) that needs to be typeset, you
might use something like:
const node = document.getElementById('hasmath');
MathJax.typesetClear([node]);
node.innerHTML = new_html;
MathJax.typesetPromise([node]).then(() => {
// the new content is has been typeset
});
The argument passed to MathJax.typestClear()
can be an actual
DOM element, as in the example above, or a CSS selector string (e.g.,
'#hasmath'
), or an array of these. The selector can specify more
than one container element (e.g., via a class selector).
If you are using automatic equation numbers and insert new content in the middle of the page, that may require the equation numbers to be adjusted throughout the page. In that case, you can do
MathJax.startup.document.state(0);
MathJax.texReset();
MathJax.typeset();
to force MathJax to reset the page to the state it was before MathJax processed it (i.e., remove its typeset math), reset the TeX automatic line numbering and labels, and then retypeset the contents of the page from scratch.
Looking up the Math on the Page¶
MathJax saves its information about a particular expression that it
has typeset in an object called a MathItem
; each typeset
expression has an associated MathItem. You can look up the MathItems
using the MathJax.startup.document.getMathItemsWithin()
function. You pass this a container element (or a CSS selector for an
element or collection of elements, or an array of containers or
selectors) and it will return an array of the MathItems that are
within those containers. E.g.,
MathJax.startup.document.getMathItemsWithin(document.body);
will return an array of all the MathItems for the typeset math on the
page. See the MathItem definition
for details on the contents of the MathItem structure. The MathItem
is the v3 replacement for the v2 ElementJax object, and
getMathItemsWithin()
performs a
similar function to the v2 function MathJax.Hub.getAllJax()
.
Typesetting UserSupplied Content¶
Mathematics formats like LaTeX and MathML allow a powerful range of
layout options, including access to hyperlinks, CSS styles, font
selection and sizing, spacing, and so on. Such features give you a
great deal of flexibility in producing the mathematics for your pages,
but if your readers are allowed to enter mathematics into your pages
(e.g., for a questionandanswer site, or in comments on a blog),
these features can be abused to cause problems for other readers and
pose a potential security risk to them. For example, the TeX
\href
command can be used to insert javascript:
links into the
page, while the \style
macro could be used to disrupt the user
interface or layout of your pages.
In order to limit the potential interference that could be caused by the mathematics entered by your readers, MathJax provides the ui/safe extension. This extension filters the mathematics on the page in order to try to remove problematic attributes, like javascript links, or font sizes that are too large or too small, or style settings that would be disruptive to the page layout. If your page allows your readers to post content that includes mathematics processed by MathJax, you should strongly consider using the ui/safe extension.
See the Safe Extension Options section for details of how to load and configure the ui/safe extension.
Loading MathJax Only on Pages with Math¶
The MathJax combined configuration files are large, and so you may wish to include MathJax in your page only if it is necessary. If you are using a contentmanagement system that puts headers and footers into your pages automatically, you may not want to include MathJax directly, unless most of your pages include math, as that would load MathJax on all your pages. Once MathJax has been loaded, it should be in the browser’s cache and load quickly on subsequent pages, but the first page a reader looks at will load more slowly. In order to avoid that, you can use a script like the following one that checks to see if the content of the page seems to include math, and only loads MathJax if it does. Note that this is not a very sophisticated test, and it may think there is math in some cases when there really isn’t but it should reduce the number of pages on which MathJax will have to be loaded.
Create a file called checkfortex.js
containing the following:
(function () {
var body = document.body.textContent;
if (body.match(/(?:\$\\\(\\\[\\begin\{.*?})/)) {
if (!window.MathJax) {
window.MathJax = {
tex: {
inlineMath: {'[+]': [['$', '$']]}
}
};
}
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/texchtml.js';
document.head.appendChild(script);
}
})();
and then use
<script src="checkfortex.js" defer></script>
in order to load the script when the page content is ready. Note
that you will want to include the path to the location where you
stored checkmathjax.js
, that you should change
texchtml.js
to whatever component file you want to use, and that
the window.MathJax
value should be set to whatever configuration
you want to use. In this case, it just adds dollar signs to the
inline math delimiters. Finally, adjust the body.match()
regular
expression to match whatever you are using for math delimiters.
This simply checks if there is something that looks like a TeX inline or displayed math delimiter, and loads MathJax if there is. If you are using different delimiters, you will need to change the pattern to include those (and exclude any that you don’t use). If you are using AsciiMath instead of TeX, then change the pattern to look for the AsciiMath delimiters.
If you are using MathML, you may want to use
if (document.body.querySelector('math')) {...}
for the test instead (provided you aren’t using namespace prefixes, like <m:math>).
Converting a Math String to Other Formats¶
An important use case for MathJax is to convert a string containing mathematics (in one of the three forms that MathJax understands) and convert it into another form (either MathML, or one of the output formats that MathJax supports). This was difficult to do in MathJax version 2, but easy to do in version 3.
When MathJax starts up, it creates methods for converting from the
input format(s) to the output format(s) that you have loaded, and to
MathML format. For example, if you have loaded the MathML input jax
and the SVG output jax (say by using the mmlsvg
component), then
MathJax will create the following conversion methods for you:
MathJax.mathml2svg(math[,options])
MathJax.mathml2svgPromise(math[,options])
MathJax.mathml2mml(math[,options])
MathJax.mathml2mmlPromise(math[,options])
If you had loaded the TeX input jax as well, you would also get four
more methods, with tex
in place of mathml
.
As the names imply, the Promise
functions perform the conversion
asynchronously, and return promises, while the others operate
synchronously and return the converted form immediately. The first
two functions (and any others like them) produce DOM elements as the
results of the conversion, with the promise versions passing that to
their then()
functions as their argument (see the section on
Asynchronous Conversion below), and the nonpromise versions returning
them directly. You can insert these DOM elements into the document
directly, or you can use their outerHTML
property to obtain
their serialized string form.
The functions that convert to MathML produce serialized MathML strings
automatically, rather than DOM elements. (You can use the browser’s
DOMParser
object to convert the string into a MathML DOM tree
if you need one.)
Conversion Options¶
All four of these functions require an argument that is the math
string to be converted (e.g., the serialized MathML string, or in the
case of tex2chtml()
, the TeX or LaTeX string). You can also
pass a second argument that is an object containing options that
control the conversion process. The options that can be included are:
display
, a boolean specifying whether the math is in displaymode or not (for TeX input). Default istrue
.em
, a number giving the number of pixels in anem
for the surrounding font. Default is16
.ex
, a number giving the number of pixels in anex
for the surrounding font. Default is8
.containerWidth
, a number giving the width of the container, in pixels. Default is 80 times theex
value.lineWidth'
, a number giving the linebreaking width inem
units. Default is a very large number (100000), so effectively no line breaking.scale
, a number giving a scaling factor to apply to the resulting conversion. Default is 1.
For example,
let html = MathJax.tex2chtml('\\sqrt{x^2+1}', {em: 12, ex: 6, display: false});
would convert the TeX expression \sqrt{x^2+1}
to HTML as an
inline expression, with em
size being 12 pixels and ex
size
being 6 pixels. The result will be a DOM element containing the HTML
for the expression. Similarly,
let html = MathJax.tex2chtml('\\sqrt{x^2+1}', {em: 12, ex: 6, display: false});
let text = html.outerHTML;
sets text
to be the serialized HTML string for the expression.
Obtaining the Output Metrics¶
Since the em
, ex
, and containerWidth
all
depend on the location where the math will be placed in the document
(they are values based on the surrounding text font and the container
elements width), MathJax provides a method for obtaining these values
from a given DOM element. The method
MathJax.getMetricsFor(node, display)
takes a DOM element (node
) and a boolean (display
), indicating
if the math is in display mode or not, and returns an object
containing all six of the options listed above. You can pass this
object directly to the conversion methods discussed above. So you can
do something like
let node = document.querySelector('#math');
let options = MathJax.getMetricsFor(node, true);
let html = MathJax.tex2svg('\\sqrt{x^2+1}', options);
node.appendChild(html);
in order to get the correct metrics for the (eventual) location of
the math that is being converted. Of course, it would be easier to
simply insert the TeX code into the page and use
MathJax.typeset()
to typeset it, but this is just an example
to show you how to obtain the metrics from a particular location in
the page.
Note that obtaining the metrics causes a page refresh, so it is expensive to do this. If you need to get the metrics from many different locations, there are more efficient ways, but these are advanced topics to be dealt with elsewhere.
Obtaining the Output Stylesheet¶
The output from the SVG and CommonHTML output jax both depend on CSS stylesheets in order to properly format their results. You can obtain the SVG stylesheet element by calling
MathJax.svgStylesheet();
and the HTML stylesheet from
MathJax.chtmlStylesheet();
The CommonHTML output jax CSS can be quite large, so the output jax tries to minimize the stylesheet by including only the styles that are actually needed for the mathematics that has been processed by the output jax. That means you should request the stylesheet only after you have typeset the mathematics itself.
Moreover, if you typeset several expressions, the stylesheet will include everything needed for all the expressions you have typeset. If you want to reset the stylesheet, then use
MathJax.startup.output.clearCache();
if the output jax is the CommonHTML output jax. So if you want to
produce the style sheet for a single expression, issue the
clearCache()
command just before the tex2chtml()
call.
Asynchronous Conversion¶
If you are converting TeX or LaTeX that might use require to load extensions, or where extensions might be autoloaded, you will either need to use one of the “full” components that include all the extensions, or preload all the extensions you need if you plan to use the synchronous calls listed above. Otherwise, you can use the promisebased calls, which handle the loading of extensions transparently.
For example,
let node = document.querySelector('#math');
let options = MathJax.getMetricsFor(node, true);
MathJax.tex2chtmlPromise('\\require{bbox}\\bbox[red]{\\sqrt{x^2+1}}', options)
.then((html) => {
node.appendChild(html);
let sheet = document.querySelector('#MJXCHTMLstyles');
if (sheet) sheet.parentNode.removeChild(sheet);
document.head.appendChild(MathJax.chtmlStylesheet());
});
would get the metrics for the element with id="math"
, convert
the TeX expression using those metrics (properly handling the
asynchronous load needed for the \require
command); then when the
expression is typeset, it is added to the document and the CHTML
stylesheet is updated.
Hosting Your Own Copy of MathJax¶
We recommend using a CDN service if you can, but you can also install MathJax on your own server, or locally on your own hard disk. You may need to do this if you are creating a custom build of MathJax, for example, or if you wish to use MathJax offline.
Acquiring the MathJax Code¶
In order to host your own version of MathJax, you must first obtain a
copy of the MathJax code. That can be done in several ways, the
easiest being to use npm
(the node package manager), or git
to
get MathJax from its GitHub development repository.
Getting MathJax via npm¶
To include MathJax in your project, use the command
npm install mathjax@3
This will install MathJax in node_modules/mathjax
subdirectory of
your current directory. It will include the prebuilt components in
the node_modules/mathjax/es5
directory. (Note that it is
important to use mathjax@3
, as we are still making v2 releases,
and so the latest mathjax npm package may not be the v3 one. The
latest
version on npmjs.com
appears to be chronological rather
than by version number.)
If you need access to the source code, as well. Then use
npm install mathjaxfull@3
which installs MathJax in the node_modules/mathjaxfull
subdirectory, the source files for the components in
node_modules/mathjaxfull/components/src
, the typescript source
files for MathJax in node_modules/mathjaxfull/ts
, and the
compiled javascript files from the typescript source in
node_modules/mathjaxfull/js
.
Getting MathJax via git¶
To obtain a copy of MathJax from the GitHub component repository, use the command
git clone https://github.com/mathjax/MathJax.git mathjax
This will install a copy of MathJax in the mathjax/es5
directory.
If you need access to the source code as well, then use
git clone https://github.com/mathjax/MathJaxsrc.git mathjax
which will install the source code for MathJax in the
mathjax
subdirectory of your current directory. You will need to
compile the typescript source files and build the component files by
hand, as they are not part of the repository itself. To do this, do
the following:
cd mathjax
npm install
npm run compile
npm run makecomponents
cd ..
This will compile the typescript source files from the mathjax/ts
directory into javascript files in the mathjax/js
directory, and
then will build the component files from mathjax/components/src
into the mathjax/es5
directory.
Make the Files Available¶
Once you have acquired the MathJax files by one of the methods
described above, you need to make the proper files available on your
web server. Note that most of the files in the MathJax distribution
are not needed on the server. For example, the mathjax/ts
directory is typescript source code for MathJax, and this is compiled
into the javascript files found in the mathjax/js
directory. But
even these are not the files you want on your server. These
javascript files are further processed into the MathJax components
stored in the mathjax/es5
files using the data in the
mathjax/components/src
directory.
It is the contents of the mathjax/es5
directory that
you want to make available on your server, as these are the files that
are served from the CDNs that provide MathJax. You should move them
to a convenient location on your server. This might be a toplevel
directory called mathjax
, for example.
Linking to you Your Copy of MathJax¶
You can include MathJax in your web page by putting
<script src="pathtoMathJax/texchtml.js" id="MathJaxscript" async></script>
in your document’s <head>
block. Here, texchtml.js
is the
combined component that you are loading, and this is just an example; you
will need to pick the one you want to use. See the section on
Configuring and Loading MathJax for more details.
The pathtoMathJax
should be replaced by the URL for the main
MathJax directory, so if you have put the mathjax/es5
directory at the top level of you server’s web site and named it
mathjax
, you could use
<script src="/mathjax/texchtml.js" id="MathJaxscript" async></script>
to load MathJax in your page. For example, your page could look like
<html>
<head>
...
<script src="/mathjax/texchtml.js" id="MathJaxscript" async></script>
</head>
<body>
...
</body>
</html>
Firefox and Local Fonts¶
Firefox’s sameorigin security policy affects its ability to load webbased fonts, as described above. This has implications not only to crossdomain loading of MathJax, but also to using MathJax locally from your hard disk. Firefox’s interpretation of the sameorigin policy for local files used to be that the “same domain” for a page is the directory where that page exists, or any of its subdirectories. This allowed MathJax to be loaded from a subdirectory of the director where the web page was loaded.
This is no longer the case with Firefox starting with version 68 and
going forward (see their documentation).
Now there is no same origin for a file://
URL (the origin for a
page loaded from a file://
URL is unique).
This means there are limited options for using MathJax in Firefox with a local copy of MathJax. The easiest option is to use the SVG output renderer rather than the CommonHTML output, as that does not require fonts to be loaded, so avoids the sameorigin issue. Alternatively, you could install the MathJax TeX fonts as system fonts so that Firefox doesn’t hav to try to load them as web fonts.
This is an unfortunate restriction for MathJax (though we understand their reasoning), but it is a limitation imposed by Firefox’s security model that MathJax can not circumvent. Currently, this is not a problem for other browsers, though there is no guarantee that it won’t be in the future.
Making a Custom Build of MathJax¶
MathJax provides a number of combined components that load everything you need to run MathJax with a given input and output format. Still, you might find that none of the ones we provide fully suit your needs, and that you would like to include additional components in the build, or perhaps want to include customized configuration options.
You can use the MathJax component build tools to make your own custom component that has exactly the pieces and configuration that you want. You can also use them to make a custom extension, for example a TeX input extension, that takes advantage of the components already loaded, but implements additional functionality. These possibilities are described in Building a Custom Component below.
It is also possible to make a completely custom build of MathJax that doesn’t use the MathJax components at all, but includes direct calls to the MathJax source files. This is described in A Custom MathJax Build below.
If you wish to include MathJax as part of a larger project, you can use either of the techniques to do that, and make a webpacked file that includes your own project code as well as MathJax.
Getting Things Ready¶
Your first step is to download a copy of MathJax via npm
or
git
, as described in the section on Acquiring the MathJax Code.
 If you use
npm
, you will want to install themathjaxfull
package rather than themathjax
package, since the former includes all the source code, in both its original and compiled forms, along with the webpacked components.
 If you use
git
, be sure to run the commands to compile and make the components, as listed in Getting MathJax via git.
In either case, you should have a js
, an es5
, and a
components
directory, either in the node_modules/mathjaxfull
directory (for npm
installations) or in the main directory (for
git
installations).
Your second step is to obtain the tools needed to package your custom
code using webpack
. Use the commands
npm install webpack
npm install webpackcli
npm install terserwebpackplugin
npm install babelloader
npm install @babel/core
npm install @babel/presetenv
to install webpack
and its needed libraries. Once this is done,
you should be able to make the components described below. The
building instructions assume you used npm
to aquire MathJax; if
you used git
, then you will need to remove
node_modules/mathjaxfull
from the paths that include them.
Building a Custom Component¶
MathJax comes with a number of predefined components, and you can use their definitions as a starting point for your own custom component. There are also custom component examples (with documentation) in the MathJax web demos repository, which are similar to the ones described here.
There are two kinds of components you could build:
 A combined component that brings together several other
components (the
texchtml
component is a combined component)
 A extension component that contains what is needed for one feature and can be loaded along with other components to add that feature to MathJax.
We describe how you can create each of these below. In both cases, you should create a directory to hold your component’s support files. You will need the main control file for the component (that includes the code that defines the component), and a webpack control file that will tell MathJax’s build tools how to handle your component. These will be discussed in the sections below.
A Custom Combined Component¶
After downloading a copy of MathJax as described in the section on
Getting Things Ready, make the directory for your component and
cd
to that directory. We will assume the directory is called
custommathjax
for this discussion.
For this example, we will create a custom build that has the TeX input
jax and the SVG output jax, and we will load the newcommand
,
ams
, and configmacros
extensions, but will not include
require
or autoload
, so the user will not be able load any
additional TeX extensions. This component also includes the
contextual menu.
The Control File¶
Create a javascript file to house the component and call it
custommathjax.js
. The file should contain the following code (we
assume here that you used npm
to install MathJax. If not, you may
need to adjust the locations in the require()
commands).
//
// Initialize the MathJax startup code
//
require('mathjaxfull/components/src/startup/lib/startup.js');
//
// Get the loader module and indicate the modules that
// will be loaded by hand below
//
const {Loader} = require('mathjaxfull/js/components/loader.js');
Loader.preLoad(
'loader', 'startup',
'core',
'input/texbase',
'[tex]/ams',
'[tex]/newcommand',
'[tex]/configmacros',
'output/svg', 'output/svg/fonts/tex.js',
'ui/menu'
);
//
// Load the components that we want to combine into one component
// (the ones listed in the preLoad() call above)
//
require('mathjaxfull/components/src/core/core.js');
require('mathjaxfull/components/src/input/texbase/texbase.js');
require('mathjaxfull/components/src/input/tex/extensions/ams/ams.js');
require('mathjaxfull/components/src/input/tex/extensions/newcommand/newcommand.js');
require('mathjaxfull/components/src/input/tex/extensions/configmacros/configmacros.js');
require('mathjaxfull/components/src/output/svg/svg.js');
require('mathjaxfull/components/src/output/svg/fonts/tex/tex.js');
require('mathjaxfull/components/src/ui/menu/menu.js');
//
// Update the configuration to include any updated values
//
const {insert} = require('mathjaxfull/js/util/Options.js');
insert(MathJax.config, {
tex: {
packages: {'[+]': ['ams', 'newcommand', 'configmacros']}
}
});
//
// Loading this component will cause all the normal startup
// operations to be performed
//
require('mathjaxfull/components/src/startup/startup.js');
This loads the various components that we want to include in the combined component, including the standard startup code so that the usual startup process is included.
The Webpack Configuration¶
Next, create the file webpack.config.js
that includes the
following:
const PACKAGE = require('mathjaxfull/components/webpack.common.js');
module.exports = PACKAGE(
'custommathjax', // the name of the package to build
'../node_modules/mathjaxfull/js', // location of the mathjax library
[], // packages to link to
__dirname, // our directory
'.' // where to put the packaged component
);
This file gives the name that will be used for this component
(custommathjax
in this case), a pointer to where the MathJax
javascript code is to be found (adjust this to suit your setup), an
array of components that we assume are already loaded when this one is
loaded (none in this case), the directory name we are working in
(always __dirname
), and the directory where we want the final
packaged component to go (the default is the
mathjaxfull/es5
directory, but we set it to the directory
containing the source files, and the component will end with
.min.js
).
Most of the real work is done by the
mathjaxfull/components/webpack.common.js
file, which is included in
the first line here.
Building the Component¶
Once these two files are ready, you are ready to build the component. First, make sure that you have obtained the needed tools as described in Getting Things Ready above. Then you should be able to use the command
node ../node_modules/mathjaxfull/components/bin/makeAll
to process your custom build. You should end up with a file
custommathjax.min.js
in the directory with the other files. If
you put this on your web server, you can load it into your web pages
in place of loading MathJax from a CDN. This file will include all
that you need to run MathJax on your pages. Just add
<script src="custommathjax.min.js" id="MathJaxscript" async></script>
to your page and you should be in business (adjust the URL to point to
wherever you have placed the custommathjax.min.js
file).
Configuring the Component¶
Note that you can still include a MathJax = {...}
definition in
your web page before loading this custom MathJax build if you want to
customize the configuration for a specific page. You could also
include configuration within the component itself, as we did for the
TeX packages
array. This will override any pageprovided
configuration, however, so if you want to provide nonstandard
defaults that can still be overridden in the page, use
//
// Update the configuration to include any updated values
//
const {insert} = require('mathjaxfull/js/util/Options.js');
insert(MathJax.config, {tex: {packages: {'[+]': ['ams', 'newcommand', 'configmacros']}}}, false);
MathJax.config = insert({
// your default options here
}, MathJax.config);
which will update the TeX packages, and then merge the user’s
configuration options into your defaults and set
MathJax.config
to the combined options.
Fonts for CommonHTML¶
If you include the CommonHTML output jax in your custom build, the
actual web fonts are not included in the webpacked file, so you will
probably need to include fontURL in the chtml
block of your configuration and have it provide a URL where the fonts
can be found. They are in the
mathjaxfull/es5/output/chtml/fonts/woffv2
directory, and
you can put them on your server, or simply point fontURL to one of
the CDN directories for the fonts.
A Custom Extension¶
Making a custom extension is very similar to making a custom combined component. The main difference is that the extension may rely on other components, so you need to tell the build system about that so that it doesn’t include the code from those other components. You also don’t load the extension file directly (like you do the combined component above), but instead include it in the load array of the loader configuration block, and MathJax loads it itself, as discussed below.
For this example, we make a custom TeX extension that defines new TeX commands implemented by javascript functions.
The commands implemented here provide the ability to generate
MathML token elements from within TeX by hand. This allows more
control over the content and attributes of the elements produced. The
macros are \mi
, \mo
, \mn
, \ms
, and \mtext
, and
they each take an argument that is the text to be used as the content
of the corresponding MathML element. The text is not further processed
by TeX, but the extension does convert sequences of the form
\uNNNN
(where the N
are hexadecimal digits) into the
corresponding unicode character; e.g., \mi{\u2460}
would produce
U+2460, a circled digit 1, as the content of an mi
element.
The Extension File¶
After downloading a copy of MathJax as described in the section on
Getting Things Ready, create a directory for the extension named
customextension
and cd
to it. Then create the file mml.js
containing the following text:
import {Configuration} from '../node_modules/mathjaxfull/js/input/tex/Configuration.js';
import {CommandMap} from '../node_modules/mathjaxfull/js/input/tex/SymbolMap.js';
import TexError from '../node_modules/mathjaxfull/js/input/tex/TexError.js';
/**
* This function prevents multiletter mi elements from being
* interpreted as TEXCLASS.OP
*/
function classORD(node) {
this.getPrevClass(node);
return this;
}
/**
* Convert \uXXXX to corresponding unicode characters within a string
*/
function convertEscapes(text) {
return text.replace(/\\u([09AF]{4})/gi, (match, hex) => String.fromCharCode(parseInt(hex,16)));
}
/**
* Allowed attributes on any token element other than the ones with default values
*/
const ALLOWED = {
style: true,
href: true,
id: true,
class: true
};
/**
* Parse a string as a set of attribute="value" pairs.
*/
function parseAttributes(text, type) {
const attr = {};
if (text) {
let match;
while ((match = text.match(/^\s*((?:data)?[az][az]*)\s*=\s*(?:"([^"]*)"(.*?))(?:\s+,\s*$)/i))) {
const name = match[1], value = match[2]  match[3]
if (type.defaults.hasOwnProperty(name)  ALLOWED.hasOwnProperty(name)  name.substr(0,5) === 'data') {
attr[name] = convertEscapes(value);
} else {
throw new TexError('BadAttribute', 'Unknown attribute "%1"', name);
}
text = text.substr(match[0].length);
}
if (text.length) {
throw new TexError('BadAttributeList', 'Can\'t parse as attributes: %1', text);
}
}
return attr;
}
/**
* The mapping of control sequence to function calls
*/
const MmlMap = new CommandMap('mmlMap', {
mi: ['mmlToken', 'mi'],
mo: ['mmlToken', 'mo'],
mn: ['mmlToken', 'mn'],
ms: ['mmlToken', 'ms'],
mtext: ['mmlToken', 'mtext']
}, {
mmlToken(parser, name, type) {
const typeClass = parser.configuration.nodeFactory.mmlFactory.getNodeClass(type);
const def = parseAttributes(parser.GetBrackets(name), typeClass);
const text = convertEscapes(parser.GetArgument(name));
const mml = parser.create('node', type, [parser.create('text', text)], def);
if (type === 'mi') mml.setTeXclass = classORD;
parser.Push(mml);
}
});
/**
* The configuration used to enable the MathML macros
*/
const MmlConfiguration = Configuration.create(
'mml', {handler: {macro: ['mmlMap']}}
);
The comments explain what this code is doing. The main piece needed
to make it a TeX extension is the Configuration
created in the
last few lines. It creates a TeX package named mml
that handles
macros through a CommandMap
named mmlMap
that is defined just
above it. That command map defines five macros described at the
beginning of this section, each of which is tied to a method named
mmlToken
in the object that follows, passing it the name of the
MathML token element to create. The mmlToken
method is the one
that is called by the TeX parser when the \mi
and other macros are
called. It gets the argument to the macro, and any optional
attributes, and creates the MathML element with the attributes, using
the argument as the text of the element.
The Webpack Configuration¶
Next, create the file webpack.config.js
that includes the
following:
const PACKAGE = require('mathjaxfull/components/webpack.common.js');
module.exports = PACKAGE(
'mml', // the name of the package to build
'../node_modules/mathjaxfull/js', // location of the mathjax library
[ // packages to link to
'components/src/core/lib',
'components/src/input/texbase/lib'
],
__dirname, // our directory
'.' // where to put the packaged component
);
This file gives the name that will be used for this component (mml
in this case), a pointer to where the MathJax javascript code is to be
found (adjust this to suit your setup), an array of components that we
assume are already loaded when this one is loaded (the core
and
texbase
components in this case), the directory name we are
working in (always __dirname
), and the directory where we want the
final packaged component to go (the default is the
mathjaxfull/es5
directory, but we set it to the directory
containing the source files, and the component will end with
.min.js
).
Most of the real work is done by the
mathjaxfull/components/webpack.common.js
file, which is included in
the first line here.
Building the Extension¶
Once these two files are ready, you are ready to build the component. First, make sure that you have obtained the needed tools as described in Getting Things Ready above. Then you should be able to use the command
node ../node_modules/mathjaxfull/components/bin/makeAll
to process your custom build. You should end up with a file
mml.min.js
in the directory with the other files. If
you put this on your web server, you can load it as a component by
putting it in the load
array of the loader
block of your
configuration, as descrinbed below.
Loading the Extension¶
To load your custom extension, you will need to tell MathJax where it
is located, and include it in the file to be loaded on startup.
MathJax allows you to define paths to locations where your extensions
are stored, and then you can refer to the extensions in that location
by using a prefix that represents that location. MathJax has a
predefined prefix, mathjax
that is the default prefix when none
is specified explicitly, and it refers to the location where the main
MathJax file was loaded (e.g., the file texsvg.js
, or
startup.js
).
You can define your own prefix to point to the location of your
extensions by using the paths
object in the loader
block of
your configuration. In our case (see code below), we add a custom
prefix, and have it point to the URL of our extension (in this case,
the same directory as the HTML file that loads it, represented by the
URL .
). We use the custom
prefix to specify
[custom]/mml.min.js
in the load
array so that our extension
will be loaded.
Finally, we add the mml
extension to the packages
array in the
tex
block of our configuration via the special notation {'[+]':
[...]}
that tells MathJax to append the given array to the existing
packages
array that is already in the configuration by default.
So this uses all the packages that were already specified, plus our
new mml
package that is defined in our extension.
The configuration and loading of MathJax now looks something like this:
<script>
MathJax = {
loader: {
load: ['[custom]/mml.min.js'],
paths: {custom: '.'}
},
tex: {
packages: {'[+]': ['mml']}
}
};
</script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/texchtml.js">
</script>
You should change the custom: '.'
line to point to the actual URL for
your server.
This example loads the texchtml.js
combined component, so the TeX
input is already loaded when our extension is loaded. If you are
using startup.js
instead, and including input/tex
in the
load
array, you will need to tell MathJax that your extension
depends on the input/tex
extension so that it waits to load your
extension until after the TeX input jax is loaded. To do that, add a
dependencies
block to your configuration like the following:
<script>
MathJax = {
loader: {
load: ['input/tex', 'output/chtml', '[custom]/mml.min.js'],
paths: {custom: '.'},
dependencies: {'[custom]/mml.min.js': ['input/tex']}
},
tex: {
packages: {'[+]': ['mml']}
}
};
</script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js">
</script>
This example can be seen live in the MathJax 3 demos repository.
A Custom MathJax Build¶
It is possible to make a completely custom build of MathJax that is not based on other MathJax components at all. The following example shows how to make a custom build that provides a function for obtaining the speech string for a given TeX math string. This example is similar to one in the MathJax3 demos repository.
After downloading a copy of MathJax as described in the section on
Getting Things Ready, create a directory called mathjaxspeech
and
cd
into it.
The Custom Build File¶
Create the custom MathJax file named mathjaxspeech.js
containing
the following:
//
// Load the desired components
//
const mathjax = require('mathjaxfull/js/mathjax.js').mathjax; // MathJax core
const TeX = require('mathjaxfull/js/input/tex.js').TeX; // TeX input
const MathML = require('mathjaxfull/js/input/mathml.js').MathML; // MathML input
const browser = require('mathjaxfull/js/adaptors/browserAdaptor.js').browserAdaptor; // browser DOM
const Enrich = require('mathjaxfull/js/a11y/semanticenrich.js').EnrichHandler; // semantic enrichment
const Register = require('mathjaxfull/js/handlers/html.js').RegisterHTMLHandler; // the HTML handler
const AllPackages = require('mathjaxfull/js/input/tex/AllPackages').AllPackages; // all TeX packages
const STATE = require('mathjaxfull/js/core/MathItem.js').STATE;
const sreReady = require('mathjaxfull/js/a11y/sre.js').sreReady(); // SRE promise;
//
// Register the HTML handler with the browser adaptor and add the semantic enrichment
//
Enrich(Register(browser()), new MathML());
//
// Initialize mathjax with a blank DOM.
//
const html = mathjax.document('', {
sre: {
speech: 'shallow', // add speech to the enriched MathML
},
InputJax: new TeX({
packages: AllPackages.filter((name) => name !== 'bussproofs'), // Bussproofs needs an output jax
macros: {require: ['', 1]} // Make \require a noop since all packages are loaded
})
});
//
// The user's configuration object
//
const CONFIG = window.MathJax  {};
//
// The global MathJax object
//
window.MathJax = {
version: mathjax.version,
html: html,
sreReady: sreReady,
tex2speech(tex, display = true) {
const math = new html.options.MathItem(tex, html.inputJax[0], display);
return mathjax.handleRetriesFor(() => math.convert(html, STATE.CONVERT)).then(() => {
let speech = '';
math.root.walkTree(node => {
const attributes = node.attributes.getAllAttributes();
console.log(attributes);
if (!speech && attributes['datasemanticspeech'] &&
!attributes['datasemanticparent']) {
speech = attributes['datasemanticspeech'];
}
});
return speech  'no speech text generated';
});
}
};
//
// Perform ready function, if there is one
//
if (CONFIG.ready) {
sreReady.then(CONFIG.ready);
}
Unlike the componentbased example above, this custom build calls on
the MathJax source files directly. The require
commands at the
beginning of the file load the needed objects, and the rest of the
code instructs MathJax to create a MathDocument
object for
handling the conversions that we will be doing (using a TeX input
jax), and then defines a global MathJax
object that has the
tex2speech()
function that our custom build offers.
The Webpack Configuration¶
Next, create the file webpack.config.js
that includes the
following:
const PACKAGE = require('mathjaxfull/components/webpack.common.js');
module.exports = PACKAGE(
'mathjaxspeech', // the name of the package to build
'../node_modules/mathjaxfull/js', // location of the mathjax library
[], // packages to link to
__dirname, // our directory
'.' // where to put the packaged component
);
This file gives the name that will be used for this component
(mathjaxspeech
in this case), a pointer to where the MathJax
javascript code is to be found (adjust this to suit your setup), an
array of components that we assume are already loaded when this one is
loaded (none, since this is a selfcontained build), the directory
name we are working in (always __dirname
), and the directory where
we want the final packaged component to go (the default is the
mathjaxfull/es5
directory, but we set it to the directory
containing the source files, and the component will end with
.min.js
).
Most of the real work is done by the
mathjaxfull/components/webpack.common.js
file, which is included in
the first line here.
Building the Custom File¶
Once these two files are ready, you are ready to make your custom build. First, make sure that you have obtained the needed tools as described in Getting Things Ready above. Then you should be able to use the command
node ../node_modules/mathjaxfull/components/bin/makeAll
to process your custom build. You should end up with a file
mathjaxspeech.min.js
in the directory with the other files. it
will contain just the parts of MathJax that are needed to implement
the MathJax.tex2speech()
command defined in the file above.
Note that this is not enough to do normal typesetting (for example, no
output jax has been included), so this is a minimal file for producing
the speech strings from TeX input.
Using the File in a Web Page¶
If you put the mathjaxspeech.min.js
file on your web server, you
can load it into your web pages in place of loading MathJax from a
CDN. This fill will include all that you need to use the
MathJax.tex2speech()
command in your pages. Just add
<script src="mathjaxspeech.min.js" id="MathJaxscript" async></script>
to your page (adjust the URL to point to wherever you have placed the
custommathjax.min.js
file). Then you can use javascript calls
like
const speech = await MathJax.tex2speech('\\sqrt{x^2+1}', true);
to obtain a text string that contains the speech text for the square root given in the TeX string.
Note, however, that the SpeechRule Engine (SRE) that underlies the
speech generation loads asynchronously, so you have to be sure that
SRE is ready before you make such a call. The mathjaxspeech.js
file provides two ways of handling the synchronization with SRE. The
first is to use the global MathJax
variable to include a
ready()
function that is called when SRE is ready. For
example,
window.speechReady = false;
window.MathJax = {
ready: () => {
window.speechReady = true;
}
};
would set the global variable speechReady
to true when SRE is
ready to run (so you can check that value to see if speech can be
generated yet). A more sophisticated ready()
function could
allow you to queue translations to be performed, and when SRE is ready,
it performs them. Alternatively, if you have a user interface that
allows users to transform TeX expressions, for example, then you could
initially disable to buttons that trigger speech generation, and use
the ready()
function to enable them. That way, the user can’t
ask for speech translation until it can be produced.
The second method of synchronizing with SRE is through the fact that
the code sets MathJax.sreReady
to a promise that is resolves
when SRE is ready, which you can use to make sure SRE is ready when you
want to do speech generation. For example
function showSpeech(tex, display = false) {
MathJax.sreReady = MathJax.sreReady.then(async () => {
const speech = await MathJax.tex2speech(tex, display);
const output = document.getElementById('speech');
output.innerHTML = '';
output.appendChild(document.createTextNode(speech));
});
}
provides a function that lets you specify a TeX string to translate,
and then (asynchronously) generates the speech for it and displays it
as the contents of the DOM element with id="speech"
in the page.
Examples in a Browser¶
There are a number of example files in the MathJax web demo repository (see the list of demos). These include documentation as well as live examples that you can run.
In addition, there are examples for:
 Configuring MathJax using an external script
 Configuring and loading MathJax using one local file
 Synchronizing with MathJax using promises
 Reseting TeX equation numbering
 Updating previously typeset content
 Looking up the math on the page
 Loading MathJax only on pages with math
 Automatic Section Numbering
Getting Started with Node¶
This page is still under construction.
See the MathJax node demos for examples of how to use MathJax from a node application. These are categorized into three groups
 Examples using MathJax components the simple way
 Examples using MathJax components via the startup module
 Examples using MathJax components loaded by hand
 Examples using MathJax modules directly.
More information will be coming to this section in the future.
Three Ways to Use MathJax in Node¶
Using MathJax Components in Node¶
This page is still under construction.
It is possible to use MathJax in a node application in essentially
the same was that it is used in a browser. in particular, you can
load MathJax components and configure MathJax using a global
MathJax
object and loading the startup
component or a combined component file
via node’s require()
command.
See the MathJax node demos for examples of how to use MathJax from a node application. in particular, see the componentbased examples for illustrations of how to use MathJax components in a node application.
More information will be coming to this section in the future.
Loading Components by Hand in NodeJS¶
This page is still under construction.
In a node application, you can load components individually yourself
via node’s require()
command, rather than relying on MathJax
loader, which operates asynchronously. This gives
you the ability to work with MathJax synchronously (i.e., without the
need to use promises). It also gives you more complete control over
the loading of components, though in this case you do need to take
care to load dependencies yourself, and to make sure the components
are loaded in the right order.
This approach lets you take advantage of using the convenient
packaging of MathJax into individual components, the configuration of
MathJax through the global MathJax
variable, and its automatic
creation of objects and methods by the startup
component, while still allowing you to work completely synchronously
with the MathJax code. (Or you can still use promises as well —
it’s up to you!)
See the MathJax node demos for examples of how to use MathJax from a node application. in particular, see the preloading examples for illustrations of how to load MathJax components by hand in a node application.
More information will be coming to this section in the future.
Linking to MathJax Directly in Node¶
This page is still under construction.
Node applications can link directly to MathJax source code, rather than using MathJax components. This provides the lowestlevel access to the MathJax code, and is more complicated than using components, but it gives you the greatest flexibility as well.
See the MathJax node demos for examples of how to use MathJax from a node application. in particular, see the noncomponentbased examples for illustrations of how to use MathJax modules directly in a node application, rather than using the prepackaged components.
More information will be coming to this section in the future.
Examples of MathJax in Node¶
This page is still under construction.
See the MathJax node demos for examples of how to use MathJax from a node application. These are categorized into three groups
 Examples using MathJax components via the startup module
 Examples using MathJax components loaded by hand
 Examples using MathJax modules directly.
More information will be coming to this section in the future.
TeX and LaTeX Support¶
The support for TeX and LaTeX in MathJax involves two functions:
the first looks for mathematics within your web page (indicated by
math delimiters like $$...$$
) and marks the mathematics for later
processing by MathJax, and the second is what converts the TeX
notation into MathJax’s internal format, where one of MathJax’s output
processors then displays it in the web page. In MathJax version 2,
these were separated into distinct components (the tex2jax
preprocessor and the TeX input jax), but in version 3, the tex2jax
functions have been folded into the TeX input jax.
The TeX input jax can be configured to look for whatever markers you want to use for your math delimiters. See the TeX configuration options section for details on how to customize the delimiters, and other options for TeX input.
The TeX input processor handles conversion of your mathematical notation into MathJax’s internal format (which is essentially MathML), and so acts as a TeX to MathML converter. The TeX input processor can also be customized through the use of extensions that define additional functionality (see the TeX and LaTeX extensions section).
Note: if you are not familiar with TeX/LaTeX, a good starting point is the LaTeX Wiki book.
Differences from Actual TeX¶
Since MathJax renders for the web and TeX is a print layout engine, there are natural limitations to which parts of TeX can be supported in a reasonable way. Accordingly, there are several differences between “real” TeX/LaTeX systems and MathJax’s TeX Input.
First and foremost, the TeX input processor implements only the
mathmode macros of TeX and LaTeX, not the textmode macros. MathJax
expects that you will use standard HTML tags to handle formatting the
text of your page; MathJax only handles the mathematics. So, for
example, MathJax does not implement \emph
or
\begin{enumerate}...\end{enumerate}
or other textmode macros or
environments. You must use HTML to handle such formatting tasks. If
you need a LaTeXtoHTML converter, you should consider other options.
There are two exception to this rule. First, MathJax supports the
\ref
macro outside of mathmode. Second, MathJax supports some
macros that add text within mathmode (such as \text{}
) as well as
$...$
and \(...\)
to switch back into mathmode, along with
\$
to escape a dollar sign. MathJax does not perform other macros
inside these text blocks, however, in general. So, for example,
\text{some \textbf{bold} text}
will produce the output “some
\textbf{bold} text”, not “some bold text”.
There is an extension (new in version 3.1) that implements a numnber
of textmode macros within the \text{}
macro and other ones that
produce textmode material. See the textmacros
documentation for details.
Second, some features in MathJax might be necessarily limited. For
example, MathJax only implements a limited subset of the array
environment’s preamble; i.e., only the l
, r
, c
, and 
characters alongside :
for dashed lines — everything else is
ignored.
TeX and LaTeX math delimiters¶
By default, the TeX processor uses the LaTeX math delimiters, which
are \(...\)
for inline math, and \[...\]
for displayed
equations. It also recognizes the TeX delimiters $$...$$
for
displayed equations, but it does not define $...$
as inline
math delimiters. That is because dollar signs appear too often in
nonmathematical settings, which could cause some text to be treated
as mathematics unexpectedly. For example, with singledollar
delimiters, “… the cost is $2.50 for the first one, and $2.00 for
each additional one …” would cause the phrase “2.50 for the first
one, and” to be treated as mathematics since it falls between dollar
signs. For this reason, if you want to use single dollar signs for
inline math mode, you must enable that explicitly in your
configuration:
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
}
};
You can use \$
to prevent a dollar sign from being treated as a
math delimiter within the text of your web page, e.g., use “… the
cost is $2.50 for the first one, and $2.00 for each additional one
…” to prevent these dollar signs from being used as math delimiters
in a web page where dollar signs have been configured to be inline
delimiters.
Note that, as opposed to true LaTeX, MathJax processes all
environments when wrapped inside math delimiters, even those like
\begin{equation}...\end{equation}
that are supposed to be used to
initiate math mode. By default, MathJax will also render all
environments outside of delimiters, e.g.,
\begin{matrix}...\end{matrix}
would be processed even if it is not
in math mode delimiters, though you are encouraged to use proper
delimiters for these cases to make your files more compatible with
actual LaTeX. This functionality can be controlled via the
processEnvironments
option in the tex configuration options.
See the tex configuration options page, for additional configuration parameters that you can specify for the TeX input processor.
TeX and LaTeX in HTML documents¶
HTML Special Characters¶
Keep in mind that your mathematics is part of an HTML document, so you
need to be aware of the special characters used by HTML as part of its
markup. There cannot be HTML tags within the math delimiters (other
than <br>
, <wbr>
, and HTML comments) as TeXformatted math
does not include HTML tags. Also, since the mathematics is initially
given as text in the page, you need to be careful that your
mathematics doesn’t look like HTML tags to the browser, which parses
the page before MathJax gets to see it. In particular, that means
that you have to be careful about things like lessthan and
greaterthan signs (<
and >
), and ampersands (&
), which
have special meaning to web browsers. For example,
... when $x<y$ we have ...
will cause a problem, because the browser will think <y
is the
beginning of a tag named y
(even though there is no such tag in
HTML). When this happens, the browser will think the tag continues up
to the next >
in the document (typically the end of the next
actual tag in the HTML file), and you may notice that you are missing
part of the text of the document. In the example above, the “<y
”
and “we have ...
” will not be displayed because the browser thinks
it is part of the tag starting at <y
. This is one indication you
can use to spot this problem; it is a common error and should be
avoided.
Usually, it is sufficient simply to put spaces around these symbols to cause the browser to avoid them, so
... when $x < y$ we have ...
should work. Alternatively, you can use the HTML entities <
,
>
and &
to encode these characters so that the browser
will not interpret them, but MathJax will. E.g.,
... when $x < y$ we have ...
Finally, there are \lt
and \gt
macros defined to make it
easier to enter <
and >
using TeXlike syntax:
... when $x \lt y$ we have ...
Again, keep in mind that the browser interprets your text before MathJax does.
Interactions with ContentManagement Systems¶
Another source of difficulty is when MathJax is used in
contentmanagement systems that have their own document processing
commands that are interpreted before the HTML page is created. For
example, many blogs and wikis use formats like Markdown to allow you
to create the content of your pages. In Markdown, the underscore is
used to indicate italics, and this usage will conflict with MathJax’s
use of the underscore to indicate a subscript. Since Markdown is
applied to the page first, it may convert your subscript markers into
italics (inserting <i>
or <em>
tags into your mathematics,
which will cause MathJax to ignore the math).
Such systems need to be told not to modify the mathematics that appears between math delimiters. That usually involves modifying the contentmanagement system itself, which is beyond the means of most page authors. If you are lucky, someone else will already have done this for you, and you may be able to find a MathJax plugin for your system using a web search.
If there is no plugin for your system, or if the plugin doesn’t handle
the subtleties of isolating the mathematics from the other markup that
it supports, then you may have to “trick” the contentmanagement
system into leaving your mathematics untouched. Most
contentmanagement systems provide some means of indicating text that
should not be modified (“verbatim” text), often for giving code
snippets for computer languages. You may be able use that to enclose
your mathematics so that the system leaves it unchanged and MathJax
can process it. For example, in Markdown, the backtick (`
) is
used to mark verbatim text, so
... we have `\(x_1 = 132\)` and `\(x_2 = 370\)` and so ...
may be able to protect the underscores from being processed by Markdown.
Alternatively, some contentmanagement systems use the backslash
(\
) as a special character for “escaping” other characters, and
you may be able to use that to prevent it from converting underscores
to italics. That is, you might be able to use
... we have $x\_1 = 132$ and $x\_2 = 370$ and so ...
to avoid the underscores from making 1 = 132$ and $x
into italics.
If your system uses backslashes in this way, that can help with italics, but it also causes difficulties in other ways. Because TeX uses this character to indicate a macro name, you need to be able to pass a backslash along to the page so that MathJax will be able to identify macro names; but if the contentmanagement system is using them as escapes, it will remove the backslashes as part of its processing, and they won’t make it into the final web page. In such systems, you may have to double the backslashes in order to obtain a single backslash in your HTML page. For example, you may have to do
\\begin{array}{cc}
a & b \\\\
c & c
\\end{array}
to get an array with the four entries a, b, c, and d in two
rows. Note in particular that if you want \\
you will have to
double both backslashes, giving \\\\
.
That may also affect how you enter the math delimiters. Since the
defaults are \(...\)
and \[...\]
, if your system uses \
as
an escape of its own, you may need to use \\(...\\)
and
\\[...\\]
instead in order to get \(...\)
and \[...\]
into
the page where MathJax can process it.
Finally, if you have enabled single dollar signs as math delimiters
and you want to include a literal dollar sign in your web page (one
that doesn’t represent a math delimiter), you will need to prevent
MathJax from using it as a math delimiter. If you also enable the
processEscapes
configuration parameter (it is enabled by default),
then you can use \$
in the text of your page to get a dollar sign
(without the backslash) in the end. Alternatively, you can use
something like <span>$</span>
to isolate the dollar sign so that
MathJax will not use it as a delimiter.
Defining TeX macros¶
You can use the \def
, \newcommand
, \renewcommand
,
\newenvironment
, \renewenvironment
, and \let
commands to
create your own macros and environments. Unlike actual TeX, however,
in order for MathJax to process such definitions, they must be
enclosed in math delimiters (since MathJax only processes macros in
mathmode). For example
\(
\def\RR{{\bf R}}
\def\bold#1{{\bf #1}}
\)
would define \RR
to produce a boldfaced “R”, and \bold{...}
to put its argument into bold face. Both definitions would be
available throughout the rest of the page.
You can include macro definitions in the macros
section of the
tex
blocks of your configuration, but they must be represented as
javascript objects. For example, the two macros above can be
predefined in the configuration by
window.MathJax = {
tex: {
macros: {
RR: "{\\bf R}",
bold: ["{\\bf #1}", 1]
}
}
};
Here you give the macro as a name: value
pair, where the name
is the name of the control sequence (without the backslash) that you
are defining, and value
is either the replacement string for the
macro (when there are no arguments) or an array consisting of the
replacement string followed by the number of arguments for the macro
and, optionally, default values for optional arguments.
Note that the replacement string is given as a javascript string literal, and the backslash has special meaning in javascript strings. So to get an actual backslash in the string you must double it, as in the examples above.
Similarly, you can create new environments with the environments
section of the tex
block of your configuration.
See configmacros Options for more details on the macros
and environments
configuration blocks.
Automatic Equation Numbering¶
The TeX input processing in MathJax can be configured to add equation numbers to displayed equations automatically. This functionality is turned off by default, but it is easy to configure MathJax to produce automatic equation numbers by adding:
window.MathJax = {
tex: {
tags: 'ams'
}
};
to tell the TeX input processor to use the AMS numbering rules (where
only certain environments produce numbered equations, as they would be
in LaTeX). It is also possible to set the tagging to 'all'
, so that
every displayed equation will get a number, regardless of the
environment used.
You can use \notag
or \nonumber
to prevent
individual equations from being numbered, and \tag{}
can be used
to override the usual equation number with your own symbol instead (or
to add an equation tag even when automatic numbering is off).
Note that the AMS environments come in two forms: starred and
unstarred. The unstarred versions produce equation numbers (when
tags
is set to 'ams'
) and the starred ones don’t. For example
\begin{equation}
E = mc^2
\end{equation}
will be numbered, while
\begin{equation*}
e^{\pi i} + 1 = 0
\end{equation*}
will not be numbered (when tags
is 'ams'
).
You can use \label
to give an equation an identifier that you can
use to refer to it later, and then use \ref
or \eqref
within
your document to insert the actual equation number at that location,
as a reference. For example,
In equation \eqref{eq:sample}, we find the value of an
interesting integral:
\begin{equation}
\int_0^\infty \frac{x^3}{e^x1}\,dx = \frac{\pi^4}{15}
\label{eq:sample}
\end{equation}
includes a labeled equation and a reference to that equation. Note that references can come before the corresponding formula as well as after them.
You can configure the way that numbers are displayed and how the
references to them by including the tagformat
extension, and
setting options within the tagformat
block of your tex
configuration. See the tagformat extension for more
details.
If you are using automatic equation numbering and modifying the page dynamically, you can run into problems due to duplicate labels. See Resetting Automatic Equation Numbering for how to address this.
TeX and LaTeX extensions¶
While MathJax includes nearly all of the Plain TeX math macros, and
many of the LaTeX macros and environments, not everything is
implemented in the core TeX input processor. Some lessused commands
are defined in extensions to the TeX processor. MathJax will load
some extensions automatically when you first use the commands they
implement (for example, the \color
macro is implemented in the
color
extension, but MathJax loads this extension itself when you
use that macro). While most extensions are set up to load
automatically, there are a few that you would need to load explicitly
yourself. See the autoload extension below for how to
configure which extensions to autoload.
Loading TeX Extensions¶
To enable one of the TeX extensions you need to do two things: load
the extension, and configure TeX to include it in its package setup.
For the first, to load an extension as a component, add its name to
the load
array in the loader
block of your MathJax
configuration. For example, to load the color
extension, add
'[tex]/color'
to the load array, as in the example below. To do
the second, add the extension name to packages
array in the
tex
block of your configuration. You can use the special
'[+]'
notation to append it to the default packages (so you don’t
need to know what they are). For example:
window.MathJax = {
loader: {load: ['[tex]/color']},
tex: {packages: {'[+]': ['color']}}
};
will load the color
extension and configure the TeX input jax to
enable it.
A number of extensions are already loaded and configured in the
components that contain the TeX extension. The input/tex
, and the
combined components containing tex
and not ending in full
include the ams
, newcommand
, noundefined
, require
,
autoload
, and configmacros
extensions, with the other
extensions being autoloaded as needed. The input/texbase
component has no extensions loaded, while the input/texfull
and
the combined extensions ending in full
load all the extensions.
If you load a component that has an extension you don’t want to use,
you can disable it by removing it from the package
array in the
tex
block of your MathJax configuration. For example, to disable
\require
and autoloading of extensions, use
window.MathJax = {
tex: {packages: {'[]': ['require', 'autoload']}}
};
if you are using, for example, the texchtml.js
combined component
file.
Loading Extensions at Run Time¶
You can also load these extensions from within a math expression using
the nonstandard \require{extension}
macro. For example
\(\require{color}\)
would load the color extension into the page. This way you you can load extensions into pages that didn’t load them in their configurations (and prevents you from having to load all the extensions into all pages even if they aren’t used).
Configuring TeX Extensions¶
Some extensions have options that control their behavior. For
example, the color extension allows you to set the padding and
borderwidth used for the \colorbox
and \fcolorbox
macros.
Such extensions are configured using a block within the tex
configuration of your MathJax configuration object. The block has the
same name as the extension, and contains the options you want to set
for that extension. For example,
window.MathJax = {
loader: {load: ['[tex]/color']},
tex: {
packages: {'[+]': ['color']},
color: {
padding: '5px'
}
}
};
would set the padding for \colorbox
to be 5 pixels.
See the Configuring MathJax section for details about how to configure MathJax in general, and TeX Extension Options for the options for individual extensions.
For extensions that are not loaded explicitly but may be loaded via
the autoload package or the \require
macro, you can’t include
the configuration within the tex
block, because MathJax will not
know the options that are available (since the extension hasn’t been
loaded yet). In that case, move the configuration block to the top
level of the MathJax configuration object and prefix it with
[tex]/
, as in:
window.MathJax = {
'[tex]/color': {
padding: '5px'
}
};
The TeX/LaTeX Extension List¶
The main extensions are described below:
action¶
The action extension gives you access to the MathML <maction>
element. It defines three new nonstandard macros:

\mathtip{math}{tip}
Use
tip
(in math mode) as tooltip formath
.

\texttip{math}{tip}
Use
tip
(plain text) as tooltip formath
.

\toggle{math1}{math2}...\endtoggle
Show
math1
, and when clicked, showmath2
, and so on. When the last one is clicked, go back tomath1
.
This extension is loaded automatically when the autoload extension
is used. To load the action extension explicitly, add
'[tex]/action'
to the load
array of the loader
block of
your MathJax configuration, and add 'action'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/action']},
tex: {packages: {'[+]': ['action']}}
};
Alternatively, use \require{action}
in a TeX expression to load it
dynamically from within the math on the page, if the require
package is loaded.
ams¶
The ams extension implements AMS math environments and macros, and
macros for accessing the characters in the AMS symbol fonts. This
extension is already loaded in all the components that include
the TeX input jax, other than input/texbase
. See the list
of control sequences for details about what commands
are implemented in this extension.
To load the ams extension explicitly (when using
input/texbase
for example), add '[tex]/ams'
to the
load
array of the loader
block of your MathJax configuration,
and add 'ams'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/ams']},
tex: {packages: {'[+]': ['ams']}}
};
Alternatively, use \require{ams}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
Since the ams extension is included in the combined components that contain the TeX input jax, it will already be in the package list. In that case, if you want to disable it, you can remove it:
window.MathJax = {
tex: {packages: {'[]': ['ams']}}
};
ams Options¶
Adding the ams extension to the packages
array defines an
ams
subblock of the tex
configuration block with the
following values:
MathJax = {
tex: {
ams: {
multlineWidth: '100%',
multlineIndent: '1em'
}
}
};

multlineWidth: '100%'
The width to use for multline environments.

multlineIndent: '1em'
The margin to use on both sides of multline environments.
Note
The mutlineWidth
option used to be in the main tex
block,
but as of version 3.2, it is now in the ams
subblock of the
tex
block. Version 3.2 includes code to move the configuration
from its old location to its new one, but that
backwardcompatibility code will be removed in a future version.
ams Commands¶
The ams extension implements the following macros:
\approxeq
, \backepsilon
, \backprime
, \backsim
, \backsimeq
, \barwedge
, \Bbbk
, \because
, \beth
, \between
, \bigstar
, \binom
, \blacklozenge
, \blacksquare
, \blacktriangle
, \blacktriangledown
, \blacktriangleleft
, \blacktriangleright
, \Box
, \boxdot
, \boxed
, \boxminus
, \boxplus
, \boxtimes
, \bumpeq
, \Bumpeq
, \Cap
, \centerdot
, \cfrac
, \checkmark
, \circeq
, \circlearrowleft
, \circlearrowright
, \circledast
, \circledcirc
, \circleddash
, \circledR
, \circledS
, \complement
, \Cup
, \curlyeqprec
, \curlyeqsucc
, \curlyvee
, \curlywedge
, \curvearrowleft
, \curvearrowright
, \daleth
, \dashleftarrow
, \dashrightarrow
, \dbinom
, \ddddot
, \dddot
, \DeclareMathOperator
, \dfrac
, \diagdown
, \diagup
, \Diamond
, \digamma
, \divideontimes
, \Doteq
, \doteqdot
, \dotplus
, \doublebarwedge
, \doublecap
, \doublecup
, \downdownarrows
, \downharpoonleft
, \downharpoonright
, \eqcirc
, \eqref
, \eqsim
, \eqslantgtr
, \eqslantless
, \eth
, \fallingdotseq
, \Finv
, \frac
, \Game
, \genfrac
, \geqq
, \geqslant
, \ggg
, \gggtr
, \gimel
, \gnapprox
, \gneq
, \gneqq
, \gnsim
, \gtrapprox
, \gtrdot
, \gtreqless
, \gtreqqless
, \gtrless
, \gtrsim
, \gvertneqq
, \hslash
, \idotsint
, \iiiint
, \impliedby
, \implies
, \injlim
, \intercal
, \Join
, \leadsto
, \leftarrowtail
, \leftleftarrows
, \leftrightarrows
, \leftrightharpoons
, \leftrightsquigarrow
, \leftthreetimes
, \leqq
, \leqslant
, \lessapprox
, \lessdot
, \lesseqgtr
, \lesseqqgtr
, \lessgtr
, \lesssim
, \lhd
, \llcorner
, \Lleftarrow
, \lll
, \llless
, \lnapprox
, \lneq
, \lneqq
, \lnsim
, \looparrowleft
, \looparrowright
, \lozenge
, \lrcorner
, \Lsh
, \ltimes
, \lvert
, \lVert
, \lvertneqq
, \maltese
, \mathring
, \measuredangle
, \mho
, \multimap
, \ncong
, \negmedspace
, \negthickspace
, \nexists
, \ngeq
, \ngeqq
, \ngeqslant
, \ngtr
, \nleftarrow
, \nLeftarrow
, \nleftrightarrow
, \nLeftrightarrow
, \nleq
, \nleqq
, \nleqslant
, \nless
, \nmid
, \nobreakspace
, \notag
, \nparallel
, \nprec
, \npreceq
, \nrightarrow
, \nRightarrow
, \nshortmid
, \nshortparallel
, \nsim
, \nsubseteq
, \nsubseteqq
, \nsucc
, \nsucceq
, \nsupseteq
, \nsupseteqq
, \ntriangleleft
, \ntrianglelefteq
, \ntriangleright
, \ntrianglerighteq
, \nvdash
, \nvDash
, \nVdash
, \nVDash
, \operatorname
, \pitchfork
, \precapprox
, \preccurlyeq
, \precnapprox
, \precneqq
, \precnsim
, \precsim
, \projlim
, \restriction
, \rhd
, \rightarrowtail
, \rightleftarrows
, \rightleftharpoons
, \rightrightarrows
, \rightsquigarrow
, \rightthreetimes
, \risingdotseq
, \Rrightarrow
, \Rsh
, \rtimes
, \rvert
, \rVert
, \shortmid
, \shortparallel
, \shoveleft
, \shoveright
, \sideset
, \SkipLimits
, \smallfrown
, \smallsetminus
, \smallsmile
, \sphericalangle
, \sqsubset
, \sqsupset
, \square
, \Subset
, \subseteqq
, \subsetneq
, \subsetneqq
, \substack
, \succapprox
, \succcurlyeq
, \succnapprox
, \succneqq
, \succnsim
, \succsim
, \Supset
, \supseteqq
, \supsetneq
, \supsetneqq
, \tag
, \tbinom
, \tfrac
, \therefore
, \thickapprox
, \thicksim
, \triangledown
, \trianglelefteq
, \triangleq
, \trianglerighteq
, \twoheadleftarrow
, \twoheadrightarrow
, \ulcorner
, \unlhd
, \unrhd
, \upharpoonleft
, \upharpoonright
, \upuparrows
, \urcorner
, \varDelta
, \varGamma
, \varinjlim
, \varkappa
, \varLambda
, \varliminf
, \varlimsup
, \varnothing
, \varOmega
, \varPhi
, \varPi
, \varprojlim
, \varpropto
, \varPsi
, \varSigma
, \varsubsetneq
, \varsubsetneqq
, \varsupsetneq
, \varsupsetneqq
, \varTheta
, \vartriangle
, \vartriangleleft
, \vartriangleright
, \varUpsilon
, \varXi
, \vDash
, \Vdash
, \veebar
, \Vvdash
, \xleftarrow
, \xrightarrow
, \yen
And the following environments:
align*
, align
, alignat*
, alignat
, aligned
, alignedat
, bmatrix
, Bmatrix
, cases
, eqnarray*
, gather*
, gather
, gathered
, matrix
, multline*
, multline
, pmatrix
, smallmatrix
, split
, subarray
, vmatrix
, Vmatrix
amscd¶
The amscd extensions implements the CD environment for commutative diagrams. See the AMScd guide for more information on how to use the CD environment.
This extension is loaded automatically when the autoload extension
is used. To load the amscd extension explicitly, add
'[tex]/amscd'
to the load
array of the loader
block of
your MathJax configuration, and add 'amscd'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/amscd']},
tex: {packages: {'[+]': ['amscd']}}
};
Alternatively, use \require{amscd}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
amscd Options¶
Adding the amscd extension to the packages
array defines an
amscd
subblock of the tex
configuration block with the
following values:
MathJax = {
tex: {
amscd: {
colspace: '5pt',
rowspace: '5pt',
harrowsize: '2.75em',
varrowsize: '1.75em',
hideHorizontalLabels: false
}
}
};

colspace: '5pt'
This gives the amount of space to use between columns in the commutative diagram.

rowspace: '5pt'
This gives the amount of space to use between rows in the commutative diagram.

harrowsize: '2.75em'
This gives the minimum size for horizontal arrows in the commutative diagram.

varrowsize: '1.75em'
This gives the minimum size for vertical arrows in the commutative diagram.

hideHorizontalLabels: false
This determines whether horizontal arrows with labels above or below will use
\smash
in order to hide the height of the labels. (Labels above or below horizontal arrows can cause excess space between rows, so setting this totrue
can improve the look of the diagram.)
amscd Commands¶
The amscd extension implements the following macros:
@
, \minCDarrowheight
, \minCDarrowwidth
And the following environments:
CD
autoload¶
The autoload extension predefines all the macros from the extensions that haven’t been loaded already so that they automatically load the needed extension when they are first used, with the exception of the physics package, since it redefines standard macros, and the ams package, due to the large number of macros it contains.
The autoload extension is loaded in all the components that include
the TeX input jax, other than input/texbase
. That means that the
TeX input jax essentially has access to all the extensions, even if
they aren’t loaded initially, and you should never have to use
\require
or load other extensions (except physics) explicitly
unless you want to.
You can control which extensions autoload will load using the
autoload
object in the tex
block of your MathJax
configuration. This object contains key: value pairs where the
key is the name of an extension, and value is an array listing the
macro names that cause that extension to be loaded. If environments
can also cause the extension to be loaded, value is an array
consisting of two subarrays, the first being the names of the macros
that cause the extension to autoload, and the second being the names
of the environments that cause the extension to be loaded.
For example,
window.MathJax = {
tex: {
autoload: {
verb: ['verb']
}
}
};
says that the \verb
command should load the verb
extension when it is first used.
If the array is empty, then that extension will not be loaded, so to prevent autoload from loading an extension, assign it the empty array. E.g.,
window.MathJax = {
tex: {
autoload: {
verb: []
}
}
};
says that the verb extension will not be autoloaded.
Note
The autoload extension defines \color
to be the one from the
color extension (the LaTeXcompatible one rather than
the nonstandard MathJax version). If you wish to use the
nonstandard version2 \color
macro from the colorv2
extension instead, use the following:
window.MathJax = {
tex: {
autoload: {
color: [],
colorv2: ['color']
}
}
};
This extension is already loaded in all the components that
include the TeX input jax, other than input/texbase
. To load the
autoload extension explicitly (when using input/texbase
for
example), add '[tex]/autoload'
to the load
array of the
loader
block of your MathJax configuration, and add
'autoload'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/autoload']},
tex: {packages: {'[+]': ['autoload']}}
};
Since the autoload extension is included in the combined components that contain the TeX input jax, it will already be in the package list. In that case, if you want to disable it, you can remove it:
window.MathJax = {
tex: {packages: {'[]': ['autload']}}
};
autoload Options¶
Adding the autoload extension to the packages
array defines an
autoload
subblock to the tex
configuration block. This block
contains key: value pairs where the key is a TeX package name, and
the value is an array of macros that cause that package to be loaded,
or an array consisting of two arrays, the first giving names of macros
and the second names of environments; the first time any of them are
used, the extension will be loaded automatically.
The default autoload definitions are the following:
MathJax = {
tex: {
autoload: expandable({
action: ['toggle', 'mathtip', 'texttip'],
amscd: [[], ['CD']],
bbox: ['bbox'],
boldsymbol: ['boldsymbol'],
braket: ['bra', 'ket', 'braket', 'set', 'Bra', 'Ket', 'Braket', 'Set', 'ketbra', 'Ketbra'],
cancel: ['cancel', 'bcancel', 'xcancel', 'cancelto'],
color: ['color', 'definecolor', 'textcolor', 'colorbox', 'fcolorbox'],
enclose: ['enclose'],
extpfeil: ['xtwoheadrightarrow', 'xtwoheadleftarrow', 'xmapsto',
'xlongequal', 'xtofrom', 'Newextarrow'],
html: ['href', 'class', 'style', 'cssId'],
mhchem: ['ce', 'pu'],
newcommand: ['newcommand', 'renewcommand', 'newenvironment', 'renewenvironment', 'def', 'let'],
unicode: ['unicode'],
verb: ['verb']
}
}
};
To prevent an extension from autoloading, set its value to an empty array. E.g., to not autoload the color extension, use
MathJax = {
tex: {
autoload: expandable({
color: []
}
}
};
If you define your own extensions, and they have a prefix other than
[tex]
, then include that in the extension name. For instance,
MathJax = {
tex: {
autoload: expandable({
'[extensions]/myExtension' : ['myMacro', 'myOtherMacro']
}
}
};
See the Loader Options section for details about how to define
your own prefixes, like the [extensions]
prefix used here.
bbox¶
The bbox extension defines a new macro for adding background colors, borders, and padding to your math expressions.

\bbox[options]{math}
puts a bounding box around
math
using the providedoptions
. The options can be one of the following: A color name used for the background color.
 A dimension (e.g.,
2px
) to be used as a padding around the mathematics (on all sides).  Style attributes to be applied to the mathematics (e.g.,
border: 1px solid red
).  A combination of these separated by commas.
Here are some examples:
\bbox[red]{x+y} % a red box behind x+y
\bbox[2pt]{x+1} % an invisible box around x+y with 2pt of extra space
\bbox[red,2pt]{x+1} % a red box around x+y with 2pt of extra space
\bbox[5px, border: 2px solid red]
% a 2px red border around the math 5px away
This extension is loaded automatically when the autoload extension
is used. To load the bbox extension explicitly, add
'[tex]/bbox'
to the load
array of the loader
block of
your MathJax configuration, and add 'bbox'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/bbox']},
tex: {packages: {'[+]': ['bbox']}}
};
Alternatively, use \require{bbox}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
boldsymbol¶
The boldsymbol extension defines the \boldsymbol
LaTeX macro
that produces a bold version of its argument, provided bold versions
of the required characters are available.
This extension is loaded automatically when the autoload extension
is used. To load the boldsymbol extension explicitly (when using
input/texbase
for example), add '[tex]/boldsymbol'
to the
load
array of the loader
block of your MathJax configuration,
and add 'boldsymbol'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/boldsymbol']},
tex: {packages: {'[+]': ['boldsymbol']}}
};
Alternatively, use \require{boldsymbol}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
braket¶
The braket extension defines the following macros for producing the braket notation and set notation used in quantum mechanics
\bra{math}
\ket{math}
\braket{math}
\set{math}
\Bra{math}
\Ket{math}
\Braket{math}
\Set{math}
and the nonstandard macros
\ketbra{math}
\Ketbra{math}
See the documentation for the LaTeX braket package for details of how these are used.
This extension is loaded automatically when the autoload extension
is used. To load the braket extension explicitly (when using
input/texbase
for example), add '[tex]/braket'
to the
load
array of the loader
block of your MathJax configuration,
and add 'braket'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/braket']},
tex: {packages: {'[+]': ['braket']}}
};
Alternatively, use \require{braket}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
braket Commands¶
The braket extension implements the following macros:
\
, \bra
, \Bra
, \braket
, \Braket
, \ket
, \Ket
, \ketbra
, \Ketbra
, \set
, \Set
, 
bussproofs¶
The bussproofs extension implements the bussproofs
style package from
LaTeX. See the CTAN page for
more information and documentation of bussproofs.
Note that there are a couple of important differences between the use
of the package in MathJax compared to actual LaTeX. First, proofs
always have to be in a prooftree environment, i.e., inference macros
are only recognised if they are enclosed in \begin{prooftree}
and
\end{prooftree}
. Consequently the \DisplayProof
command is not
necessary.
Second, unlike in the LaTeX package, options for abbreviated inference
rule macros do not have to be manually set. All abbreviated macros are
directly available. Thus commands like \BinaryInfC
and \BIC
can be used immediately and interchangeably.
For example:
\begin{prooftree}
\AxiomC{}
\RightLabel{Hyp$^{1}$}
\UnaryInfC{$P$}
\AXC{$P\to Q$}
\RL{$\to_E$}
\BIC{$Q^2$}
\AXC{$Q\to R$}
\RL{$\to_E$}
\BIC{$R$}
\AXC{$Q$}
\RL{Rit$^2$}
\UIC{$Q$}
\RL{$\wedge_I$}
\BIC{$Q\wedge R$}
\RL{$\to_I$$^1$}
\UIC{$P\to Q\wedge R$}
\end{prooftree}
Also note that the bussproofs commands for sequent calculus derivations are not yet fully implemented.
This extension is loaded automatically when the autoload extension
is used. To load the bussproofs extension explicitly, add
'[tex]/bussproofs'
to the load
array of the loader
block
of your MathJax configuration, and add 'bussproofs'
to the
packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/bussproofs']},
tex: {packages: {'[+]': ['bussproofs']}}
};
Alternatively, use \require{bussproofs}
in a TeX expression to
load it dynamically from within the math on the page, if the require
extension is loaded.
bussproofs Commands¶
The bussproofs extension implements the following macros:
\alwaysDashedLine
, \alwaysNoLine
, \alwaysRootAtBottom
, \alwaysRootAtTop
, \alwaysSingleLine
, \alwaysSolidLine
, \AXC
, \Axiom
, \AxiomC
, \BIC
, \BinaryInf
, \BinaryInfC
, \dashedLine
, \fCenter
, \LeftLabel
, \LL
, \noLine
, \QuaternaryInf
, \QuaternaryInfC
, \QuinaryInf
, \QuinaryInfC
, \RightLabel
, \RL
, \rootAtBottom
, \rootAtTop
, \singleLine
, \solidLine
, \TIC
, \TrinaryInf
, \TrinaryInfC
, \UIC
, \UnaryInf
, \UnaryInfC
And the following environments:
prooftree
cancel¶
The cancel extension defines the following macros:

\cancel{math}
Strikeout
math
from lower left to upper right.

\bcancel{math}
Strikeout
math
from upper left to lower right.

\xcancel{math}
Strikeout
math
with an “X”.

\cancelto{value}{math}
Strikeout
math
with an arrow going tovalue
.
This extension is loaded automatically when the autoload extension
is used. To load the cancel extension explicitly, add
'[tex]/cancel'
to the load
array of the loader
block of
your MathJax configuration, and add 'cancel'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/cancel']},
tex: {packages: {'[+]': ['cancel']}}
};
Alternatively, use \require{cancel}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
cancel Commands¶
The cancel extension implements the following macros:
\bcancel
, \cancel
, \cancelto
, \xcancel
cases¶
The cases extension implements the cases
style package from LaTeX. It
provides environments numcases
and subnumcases
for formulas with
separately enumerated cases. See the CTAN page for more information and documentation of
cases.
This package is not autoloaded, so you must request it explicitly if you want to use it.
To load the cases extension, add '[tex]/cases'
to the load
array of the loader
block of your
MathJax configuration, and add 'cases'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/cases']},
tex: {packages: {'[+]': ['cases']}}
};
You can configure the autoload extension to load cases via
window.MathJax = {
tex: {
autoload: {
cases: [[], ['numcases', 'subnumcases']]
}
}
};
Alternatively, use \require{cases}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
cases Commands¶
The cases extension implements the following macros:
&
And the following environments:
numcases
, subnumcases
centernot¶
The centernot extension implements the centernot
style package from
LaTeX. It provides the \centernot
command which can be used as a replacement
of the standard \not
command and generally leads to a better alignment of
the slash with the operator it negates. This can be observed with the following
two examples:
\begin{array}{c}
A \not\longrightarrow B\\
A \centernot\longrightarrow B
\end{array}
\begin{array}{c}
A \nparallel B\\
A \not\parallel B\\
A \centernot\parallel B
\end{array}
See also the CTAN page for more information and documentation of centernot.
In addition to \centernot
the package also implements the nonstandard
\centerOver
.

centerOver{symbol1}{symbol2}
Overlays
symbol2
centered on top ofsymbol1
.
This package is not autoloaded, so you must request it explicitly if you want to
use it. To load the centernot extension, add '[tex]/centernot'
to the
load
array of the loader
block of your MathJax configuration, and add
'centernot'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/centernot']},
tex: {packages: {'[+]': ['centernot']}}
};
You can configure the autoload extension to load centernot via
window.MathJax = {
tex: {
autoload: {
centernot: ['centernot', 'centerOver']
}
}
};
Alternatively, use \require{centernot}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
centernot Commands¶
The centernot extension implements the following macros:
\centernot
, \centerOver
color¶
The color extension defines the \color
macro as in the LaTeX
color package, along with \colorbox
, \fcolorbox
, and
\definecolor
. It declares the standard set of colors (Apricot,
Aquamarine, Bittersweet, and so on), and provides the RGB, rgb,
and greyscale color spaces in addition to named colors.
This extension is loaded automatically when the autoload extension
is used. To load the color extension explicitly, add
'[tex]/color'
to the load
array of the loader
block of
your MathJax configuration, and add 'color'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/color']},
tex: {packages: {'[+]': ['color']}}
};
Alternatively, use \require{color}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
Note
In version 2, a nonstandard \color
macro was the default
implementation, but in version 3, the standard LaTeX one is now the
default. The difference between the two is that the standard
\color
macro is a switch (everything that follows it is in the
new color), whereas the nonstandard version 2 \color
macro
takes an argument that is the mathematics to be colored. That is,
in version 2, you would do
\color{red}{x} + \color{blue}{y}
to get a red x added to a blue y. But in version 3 (and in LaTeX itself), you would do
{\color{red} x} + {\color{blue} y}
If you want the old version 2 behavior, use the colorv2 extension instead.
color Options¶
Adding the color extension to the packages
array defines a
color
subblock of the tex
configuration block with the
following values:
MathJax = {
tex: {
color: {
padding: '5px',
borderWidth: '2px'
}
}
};

padding: '5px'
This gives the padding to use for color boxes with background colors.

borderWidth: '2px'
This gives the border width to use with framed color boxes produced by
\fcolorbox
.
color Commands¶
The color extension implements the following macros:
\color
, \colorbox
, \definecolor
, \fcolorbox
, \textcolor
colortbl¶
The colortbl extension partially implements the colortbl
style package
from LaTeX. It allows coloring of rows, columns and individual cell of tables.
See the CTAN page for more information
and documentation of colortbl. But note that MathJax currently does not
implement any commands for styling or coloring table boundaries. In addition,
MathJax implement some of the colortbl commands differently:

rowcolor[model]{color}
Allows to color a single row in a table. It needs to be used in the first cell of a row to color. If used elsewhere an error is thrown.

columncolor[model]{color}
Allows to color a single column. It needs to be used in the first cell of the column to color. If used elsewhere an error is thrown.
Note, that it is unlike its LaTeX counterpart that is used in the layout specification of a table environment (e.g.,
array
). While MathJax will not throw an error of a\columncolor
is used in the arguments of the table environment, it will be ignored.In addition overhang arguments are currently not handled. That is MathJax ignores up to two optional bracketed arguments after the mandatory color argument.

cellcolor[model]{color}
Allows to color a single cell. It can be used anywhere in the cell to color.
The order of precendence of the color commands is as follows: \cellcolor > \rowcolor > \columncolor
.
See the example below for all three commands in action.
\begin{array}{lc}
\rowcolor[gray]{.5}\columncolor{red} one & two\\
\rowcolor{lightblue} three & four\\\hline
five & six \\
\rowcolor{magenta}seven & \cellcolor{green}eight
\end{array}
This package is not autoloaded, so you must request it explicitly if you want to use it.
To load the colortbl extension, add '[tex]/colortbl'
to the load
array of the loader
block of your
MathJax configuration, and add 'colortbl'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/colortbl']},
tex: {packages: {'[+]': ['colortbl']}}
};
You can configure the autoload extension to load colortbl via
window.MathJax = {
tex: {
autoload: {
colortbl: ['cellcolor', 'columncolor', 'rowcolor']
}
}
};
Alternatively, use \require{colortbl}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
colortbl Commands¶
The colortbl extension implements the following macros:
\cellcolor
, \columncolor
, \rowcolor
colorv2¶
The colorv2 extension defines the \color
macro to be the
nonstandard macro that is the default in MathJax version 2, namely,
it takes two arguments, one the name of the color (or an HTML color of
the form #RGB
or #RRGGBB
), and the second the math to be
colored. This is in contrast to the standard LaTeX \color
command, which is a switch that changes the color of everything that
follows it.
This extension is not loaded automatically when the autoload
extension is used. To load the color extension explicitly, add
'[tex]/color'
to the load
array of the loader
block of
your MathJax configuration, and add 'color'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/colorv2']},
tex: {packages: {'[+]': ['color']}}
};
or, use \require{colorv2}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
Alternatively, you can configure the autoload package to load
colorv2 when \color
is used rather than the (LaTeXcompatible)
color extension:
window.MathJax = {
tex: {
autoload: {
color: [], // don't autoload the color extension
colorv2: ['color'] // autoload colorv2 on the first use of \color
}
}
};
configmacros¶
The configmacros extension provides the macros
and
environments
configuration options for the tex
block of your
MathJax configuration. This allows you to predefine custom macros end
environments for your page using javascript. For example,
window.MathJax = {
tex: {
macros: {
RR: "{\\bf R}",
bold: ["{\\bf #1}", 1]
},
environments: {
braced: ["\\left\\{", "\\right\\}"]
}
}
};
defines a macro \RR
that produces a bold “R”, while
\bold{math}
typesets the math
using the bold font (see
Defining TeX macros for more information). It also creates the
braced
environment that puts \left\{
and \right\}
around
its contents.
This extension is already loaded in all the components that
include the TeX input jax, other than input/texbase
. To load the
configmacros extension explicitly (when using input/texbase
for
example), add '[tex]/configmacros'
to the load
array of the
loader
block of your MathJax configuration, and add
'configmacros'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/configmacros']},
tex: {packages: {'[+]': ['configmacros']}}
};
Since the configmacros extension is included in the combined components that contain the TeX input jax, it may already be in the package list. In that case, if you want to disable it, you can remove it:
window.MathJax = {
tex: {packages: {'[]': ['configmacros']}}
};
configmacros Options¶
The configmacros extension adds a macros
option to the tex
block that lets you predefine macros, and the environments
option
that lets you predefine your own environments.

macros: {}
This lists macros to define before the TeX input processor begins. These are name: value pairs where the name gives the name of the TeX macro to be defined, and value gives the replacement text for the macro. The value can be a simple replacement string, or an array of the form [value, n], where value is the replacement text and n is the number of parameters for the macro. The array can have a third entry: either a string that is the default value to give for an optional (bracketed) parameter when the macro is used, or an array consisting of template strings that are used to separate the various parameters. The first template must precede the first parameter, the second must precede the second, and so on until the final which must end the last parameter to the macro. See the examples below.
Note that since the value is a javascript string, backslashes in the replacement text must be doubled to prevent them from acting as javascript escape characters.
For example,
macros: { RR: '{\\bf R}', // a simple string replacement bold: ['\\boldsymbol{#1}',1] , // this macro has one parameter ddx: ['\\frac{d#2}{d#1}', 2, 'x'], // this macro has an optional parameter that defaults to 'x' abc: ['(#1)', 1, [null, '\\cba']] // equivalent to \def\abc#1\cba{(#1)} }
would ask the TeX processor to define four new macros:
\RR
, which produces a boldface “R”, and\bold{...}
, which takes one parameter and sets it in the boldface font,\ddx
, which has an optional (bracketed) parameter that defaults tox
, so that\ddx{y}
produces\frac{dy}{dx}
while\ddx[t]{y}
produces\frac{dy}{dt}
, and\abc
that is equivalent to\def\abc#1\cba{(#1)}
.

environments: {}
This lists environments to define before the TeX input processor begins. These are name: value pairs where the name gives the name of the environment to be defined, and value gives an array that defines the material to go before and after the content of the environment. The array is of the form [before, after, n, opt] where before is the material that replaces the
\begin{name}
, after is the material that replaces\end{name}
, n is the number of parameters that follow the\begin{name}
, and opt is the default value used for an optional parameter that would follow\begin{name}
in brackets. The parameters can be inserted into the before string using#1
,#2
, etc., where#1
is the optional parameter, if there is one.Note that since the before and after values are javascript strings, backslashes in the replacement text must be doubled to prevent them from acting as javascript escape characters.
For example,
environments: { braced: ['\\left\\{', '\\right\\}'], ABC: ['(#1)(#2)(', ')', 2, 'X'] }
would define two environments,
braced
andABC
, where\begin{braced} \frac{x}{y} \end{braced}
would produce the fraction x/y in braces that stretch to the height of the fraction, while
\begin{ABC}{Z} xyz \end{ABC}
would produce
(X)(Z)(xyz)
, and\begin{ABC}[Y]{Z} xyz \end{ABC}
would produce
(Y)(Z)(xyz)
.
empheq¶
The empheq extension partially implements the empheq
style package from
LaTeX. The package provides macros and environments for emphasising equations.
See the list of control sequences for details about
what commands are implemented in this extension. Note, that the current
implementation of the empheq
environment supports only the left
and
right
options. Also see the CTAN page
for more information and documentation of empheq.
This package is not autoloaded, so you must request it explicitly if you want to use it.
To load the empheq extension, add '[tex]/empheq'
to the load
array of the loader
block of your
MathJax configuration, and add 'empheq'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/empheq']},
tex: {packages: {'[+]': ['empheq']}}
};
You can configure the autoload extension to load empheq when the
empheq
environment is first used via
window.MathJax = {
tex: {
autoload: {
empheq: [[], ['empheq']]
}
}
};
Alternatively, use \require{empheq}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
empheq Commands¶
The empheq extension implements the following macros:
\empheqbigl
, \empheqbiglangle
, \empheqbiglbrace
, \empheqbiglbrack
, \empheqbiglceil
, \empheqbiglfloor
, \empheqbiglparen
, \empheqbiglvert
, \empheqbiglVert
, \empheqbigr
, \empheqbigrangle
, \empheqbigrbrace
, \empheqbigrbrack
, \empheqbigrceil
, \empheqbigrfloor
, \empheqbigrparen
, \empheqbigrvert
, \empheqbigrVert
, \empheql
, \empheqlangle
, \empheqlbrace
, \empheqlbrack
, \empheqlceil
, \empheqlfloor
, \empheqlparen
, \empheqlvert
, \empheqlVert
, \empheqr
, \empheqrangle
, \empheqrbrace
, \empheqrbrack
, \empheqrceil
, \empheqrfloor
, \empheqrparen
, \empheqrvert
, \empheqrVert
And the following environments:
empheq
enclose¶
The enclose extension gives you access to the MathML <menclose>
element for adding boxes, ovals, strikethroughs, and other marks over
your mathematics. It defines the following nonstandard macro:

\enclose{notation}[attributes]{math}
Where
notation
is a commaseparated list of MathML<menclose>
notations (e.g.,circle
,left
,updiagonalstrike
,longdiv
, etc.),attributes
are MathML attribute values allowed on the<menclose>
element (e.g.,mathcolor="red"
,mathbackground="yellow"
), andmath
is the mathematics to be enclosed. See the MathML 3 specification for more details on<menclose>
.
For example
\enclose{circle}[mathcolor="red"]{x}
\enclose{circle}[mathcolor="red"]{\color{black}{x}}
\enclose{circle,box}{x}
\enclose{circle}{\enclose{box}{x}}
This extension is loaded automatically when the autoload extension
is used. To load the enclose extension explicitly, add
'[tex]/enclose'
to the load
array of the loader
block of
your MathJax configuration, and add 'enclose'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/enclose']},
tex: {packages: {'[+]': ['enclose']}}
};
Alternatively, use \require{enclose}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
extpfeil¶
The extpfeil extension adds more macros for producing extensible
arrows, including \xtwoheadrightarrow
, \xtwoheadleftarrow
,
\xmapsto
, \xlongequal
, \xtofrom
, and a nonstandard
\Newextarrow
for creating your own extensible arrows. The latter
has the form

\Newextarrow{\cs}{lspace,rspace}{unicodechar}
where
\cs
is the new control sequence name to be defined,lspace
andrspace
are integers representing the amount of space (in suitably small units) to use at the left and right of text that is placed above or below the arrow, andunicodechar
is a number representing a unicode character position in either decimal or hexadecimal notation.
For example
\Newextarrow{\xrightharpoonup}{5,10}{0x21C0}
defines an extensible right harpoon with barb up. Note that MathJax knows how to stretch only a limited number of characters, so you may not actually get a stretchy character this way. The characters that can be stretched may also depend on the font you have selected.
This extension is loaded automatically when the autoload extension
is used. To load the extpfeil extension explicitly, add
'[tex]/extpfeil'
to the load
array of the loader
block of
your MathJax configuration, and add 'extpfeil'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/extpfeil']},
tex: {packages: {'[+]': ['extpfeil']}}
};
Alternatively, use \require{extpfeil}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
extpfeil Commands¶
The extpfeil extension implements the following macros:
\Newextarrow
, \xlongequal
, \xmapsto
, \xtofrom
, \xtwoheadleftarrow
, \xtwoheadrightarrow
gensymb¶
The gensymb extension implements the gensymb
style package from LaTeX. It
provides a number of macros for unit notation. See the CTAN page for more information and documentation of
gensymb.
Note that not all the characters for this package are yet included in the MathJax fonts so output might vary on clients.
This package is not autoloaded, so you must request it explicitly if you want to use it.
To load the gensymb extension, add '[tex]/gensymb'
to the load
array of the loader
block of your
MathJax configuration, and add 'gensymb'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/gensymb']},
tex: {packages: {'[+]': ['gensymb']}}
};
You can configure the autoload extension to load gensymb via
window.MathJax = {
tex: {
autoload: {
gensymb: ['celsius', 'degree', 'micro', 'ohm', 'perthousand']
}
}
};
Alternatively, use \require{gensymb}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
gensymb Commands¶
The gensymb extension implements the following macros:
\celsius
, \degree
, \micro
, \ohm
, \perthousand
html¶
The html extension gives you access to some HTML features like styles, classes, element ID’s, and clickable links. It defines the following nonstandard macros:

\href{url}{math}
Makes
math
be a link to the page given byurl
. Note that the url is not processed by TeX, but is given as the literal url. In actual TeX or LaTeX, special characters must be escaped; so, for example, a url containing a#
would need to use\#
in the url in actual TeX. That is not necessary in MathJax, and if you do use\#
, it will produce/#
in the url (since the\
will be inserted into the url verbatim, and browsers will convert that to/
(thinking it is a DOS directory separator).

\class{name}{math}
Attaches the CSS class
name
to the output associated withmath
when it is included in the HTML page. This allows your CSS to style the element.

\cssId{id}{math}
Attaches an id attribute with value
id
to the output associated withmath
when it is included in the HTML page. This allows your CSS to style the element, or your javascript to locate it on the page.

\style{css}{math}
Adds the give
css
declarations to the element associated withmath
.
For example:
x \href{whyequal.html}{=} y^2 + 1
(x+1)^2 = \class{hidden}{(x+1)(x+1)}
(x+1)^2 = \cssId{step1}{\style{visibility:hidden}{(x+1)(x+1)}}
Note
For the \href
macro, the url parameter is not processed
futher, as it is in actual TeX, so you do not need to quote special
characters. For example, \href{#section1}{x}
is fine, but
\href{\#section}{x}
will not work as expected.
This extension is loaded automatically when the autoload extension
is used. To load the html extension explicitly, add
'[tex]/html'
to the load
array of the loader
block of
your MathJax configuration, and add 'html'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/html']},
tex: {packages: {'[+]': ['html']}}
};
Alternatively, use \require{html}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
mathtools¶
The mathtools extension implements the mathtools
style package from
LaTeX. The package provides a number of tools for advanced mathematical
typesetting. See the CTAN page for
more information and documentation of mathtools.
This package is not autoloaded, so you must request it explicitly if you want to use it.
To load the mathtools extension, add '[tex]/mathtools'
to the load
array of the loader
block of your
MathJax configuration, and add 'mathtools'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/mathtools']},
tex: {packages: {'[+]': ['mathtools']}}
};
Alternatively, use \require{mathtools}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
mathtools Options¶
Adding the mathtools extension to the packages
array defines an
mathtools
subblock of the tex
configuration block with the
following values:
MathJax = {
tex: {
mathtools: {
multlinegap: '1em',
multlinedpos: 'c',
firstlineafterskip: '',
lastlinepreskip: '',
smallmatrixalign: 'c',
shortvdotsadjustabove: '.2em',
shortvdotsadjustbelow: '.2em',
centercolon: false,
centercolonoffset: '.04em',
thincolondx: '.04em',
thincolondw: '.08em',
useunicode: false,
prescriptsubformat: '',
prescriptsupformat: '',
prescriptargformat: '',
allowmathtoolsset: true,
pairedDelimiters: {},
tagforms: {}
}
}
};

multlinegap: '1em'
Horizontal space for multlined environments.

multlinedpos: 'c'
Default alignment for multlined environments.

firstlineafterskip: ''
Space for first line of multlined (overrides multlinegap).

lastlinepreskip: ''
Space for last line of multlined (overrides multlinegap).

smallmatrixalign: 'c'
Default alignment for smallmatrix environments.

shortvdotsadjustabove: '.2em'
Space to remove above \shortvdots
.

shortvdotsadjustbelow: '.2em'
Space to remove below \shortvdots
.

centercolon: false
True to have colon automatically centered.

centercolonoffset: '.04em'
Vertical adjustment for centered colons.

thincolondx: '.04em'
Horizontal adjustment for thin colons (e.g., \coloneqq
).

thincolondw: '.08em'
Width adjustment for thin colons.

useunicode: false
True to use unicode characters rather than multicharacter version for \coloneqq
, etc., when possible.

prescriptsubformat: ''
Format for \prescript
subscript.

prescriptsupformat: ''
Format for \prescript
superscript.

prescriptargformat: ''
Format for \prescript
base.

allowmathtoolsset: true
True to allow \mathtoolsset
to change settings.

pairedDelimiters: {}
Predefined paired delimiters of the form name: [left, right, body, argcount, pre, post]
.

tagforms: {}
Tag form definitions of the form name: [left, right, format]
.
mathtools Commands¶
The mathtools extension implements the following macros:
\:
, \Aboxed
, \adjustlimits
, \ArrowBetweenLines
, \bigtimes
, \centercolon
, \clap
, \colonapprox
, \Colonapprox
, \coloneq
, \Coloneq
, \coloneqq
, \Coloneqq
, \colonsim
, \Colonsim
, \cramped
, \crampedclap
, \crampedllap
, \crampedrlap
, \crampedsubstack
, \dblcolon
, \DeclarePairedDelimiters
, \DeclarePairedDelimitersX
, \DeclarePairedDelimitersXPP
, \eqcolon
, \Eqcolon
, \eqqcolon
, \Eqqcolon
, \lparen
, \mathclap
, \mathllap
, \mathmakebox
, \mathmbox
, \mathrlap
, \mathtoolsset
, \MoveEqLeft
, \MTFlushSpaceAbove
, \MTFlushSpaceBelow
, \MTThinColon
, \ndownarrow
, \newtagform
, \nuparrow
, \ordinarycolon
, \overbracket
, \prescript
, \refeq
, \renewtagform
, \rparen
, \shortvdotswithin
, \shoveleft
, \shoveright
, \splitdfrac
, \splitfrac
, \textclap
, \textllap
, \textrlap
, \underbracket
, \usetagform
, \vdotswithin
, \xhookleftarrow
, \xhookrightarrow
, \xLeftarrow
, \xleftharpoondown
, \xleftharpoonup
, \xleftrightarrow
, \xLeftrightarrow
, \xleftrightharpoons
, \xmapsto
, \xmathstrut
, \xRightarrow
, \xrightharpoondown
, \xrightharpoonup
, \xrightleftharpoons
And the following environments:
bmatrix*
, Bmatrix*
, bsmallmatrix*
, Bsmallmatrix*
, bsmallmatrix
, Bsmallmatrix
, cases*
, crampedsubarray
, dcases*
, dcases
, drcases*
, drcases
, lgathered
, matrix*
, multlined
, pmatrix*
, psmallmatrix*
, psmallmatrix
, rcases*
, rcases
, rgathered
, smallmatrix*
, spreadlines
, vmatrix*
, Vmatrix*
, vsmallmatrix*
, Vsmallmatrix*
, vsmallmatrix
, Vsmallmatrix
mhchem¶
The mhchem extensions implements the \ce
and \pu
chemical equation macros of the LaTeX mhchem package. See the
mhchem home page for more
information and documentation for mhchem.
For example
\ce{C6H5CHO}
\ce{$A$ >[\ce{+H2O}] $B$}
\ce{SO4^2 + Ba^2+ > BaSO4 v}
This extension is loaded automatically when the autoload extension
is used. To load the mhchem extension explicitly, add
'[tex]/mhchem'
to the load
array of the loader
block of
your MathJax configuration, and add 'mhchem'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/mhchem']},
tex: {packages: {'[+]': ['mhchem']}}
};
Alternatively, use \require{mhchem}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
Note
The implementation of the mhchem extension was completely rewritten for MathJax by the author of the original LaTeX package. The older version was still available MathJax version 2.7, but it is no longer part of MathJax version 3. Only the newer version of mhchem is available.
mhchem Commands¶
The mhchem extension implements the following macros:
\ce
, \longleftrightarrows
, \longLeftrightharpoons
, \longrightleftharpoons
, \longRightleftharpoons
, \pu
, \tripledash
, \xleftarrow
, \xleftrightarrow
, \xLeftrightharpoons
, \xrightarrow
, \xrightleftharpoons
, \xRightleftharpoons
newcommand¶
The newcommand extension provides the \def
, \newcommand
,
\renewcommand
, \let
, \newenvironment
, and
\renewenvironment
macros for creating new macros and environments
in TeX. For example,
\(
\def\RR{{\bf R}}
\def\bold#1{{\bf #1}}
\)
defines a macro \RR
that produces a bold “R”, while
\bold{math}
typesets its argument using a bold font. See
Defining TeX macros for more information.
This extension is already loaded in all the components that
include the TeX input jax, other than input/texbase
. To load the
newcommand extension explicitly (when using input/texbase
for
example), add '[tex]/newcommand'
to the load
array of the
loader
block of your MathJax configuration, and add
'newcommand'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/newcommand']},
tex: {packages: {'[+]': ['newcommand']}}
};
Alternatively, use \require{newcommand}
in a TeX expression to load it
dynamically from within the math on the page, if the require
package is loaded.
Since the nnewcommand extension is included in the combined components that contain the TeX input jax, it may already be in the package list. In that case, if you want to disable it, you can remove it:
window.MathJax = {
tex: {packages: {'[]': ['newcommand']}}
};
newcommand Commands¶
The newcommand extension implements the following macros:
\def
, \let
, \newcommand
, \newenvironment
, \renewcommand
, \renewenvironment
noerrors¶
The noerrors extension prevents TeX error messages from being displayed and shows the original TeX code instead.
Note
In version 2 of MathJax, you could configure the CSS that applied to the display of the original TeX. In version 3, the original TeX is shown via an merror MathML element instead.
Note
In version 2, this extension was included in all the combined configuration files that contain the TeX input jax, but in MathJax version 3, you must load it explicitly if you want to use it.
To load the noerrors extension, add '[tex]/noerrors'
to the
load
array of the loader
block of your MathJax configuration,
and add 'noerrors'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/noerrors']},
tex: {packages: {'[+]': ['noerrors']}}
};
noundefined¶
The noundefined extension causes undefined control sequences to be
shown as their macro names rather than generating error messages. So
$X_{\xyz}$
would display as an “X” with a subscript consisting of the
text \xyz
in red.
Note
In version 2, the styling for the undefined macro could be configured. In version 3, this is not yet implemented.
This extension is already loaded in all the components that
include the TeX input jax, other than input/texbase
. To load the
ams extension explicitly (when using input/texbase
for
example), add '[tex]/noundefined'
to the load
array of the loader
block of your MathJax configuration, and add 'noundefined'
to the
packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/noundefined']},
tex: {packages: {'[+]': ['noundefined']}}
};
Since the noundefined extension is included in the combined components that contain the TeX input jax, it may already be in the package list. In that case, if you want to disable it, you can remove it:
window.MathJax = {
tex: {packages: {'[]': ['noundefined']}}
};
noundefined Options¶
Adding '[tex]/noundefined'
to the packages
array defines a
noundefined
subblock of the tex
configuration block with the
following values:
MathJax = {
tex: {
noundefined: {
color: 'red',
background: '',
size: ''
}
}
};

color: 'red'
This gives the color to use for the text of the undefined macro name, or an empty string to make the color the same as the surrounding mathematics.

background: ''
This gives the color to use for the background for the undefined macro name, or an empty srting to have no brackground color.

size: ''
This gives the size to use for the undefined macro name (e.g.,
90%
or12px
), or an emtpy string to keep the size the same as the surrounding mathematics.
physics¶
The physics extension implements much of the LaTeX physics package, which defines simple, yet flexible macros for typesetting equations via:
 Automatic bracing
 Vector notation
 Derivatives
 Dirac braket notation
 Matrix macros
 Additional trig functions and other convenient operators
 Flat fractions and other useful miscellaneous math macros
See the documentation for the LaTeX package for more information.
This package is not autoloaded, due to the fact that it redefines many
standard macros, so you must request it explicitly if you want to use
it. To load the physics extension, add '[tex]/physics'
to the
load
array of the loader
block of your MathJax configuration,
and add 'physics'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/physics']},
tex: {packages: {'[+]': ['physics']}}
};
Alternatively, use \require{physics}
in a TeX expression to load it
dynamically from within the math on the page, if the require
package is loaded.
physics Options¶
Adding the physics extension to the packages
array defines an
physics
subblock of the tex
configuration block with the
following values:
MathJax = {
tex: {
physics: {
italicdiff: false,
arrowdel: false
}
}
};

italicdiff: false
This corresponds to the italicdiff
option of the physics LaTeX package to
use italic form for the d in the \differential
and \derivative`
commands.

arrowdel: false
This corresponds to the arrowdel
option of the physics LaTeX package to
use vector notation over the nabla symbol.
Note, that the physics extension does not implement the notrig option.
physics Commands¶
The physics extension implements the following macros:
\abs
, \absolutevalue
, \acomm
, \acos
, \acosecant
, \acosine
, \acot
, \acotangent
, \acsc
, \admat
, \anticommutator
, \antidiagonalmatrix
, \arccos
, \arccosecant
, \arccosine
, \arccot
, \arccotangent
, \arccsc
, \arcsec
, \arcsecant
, \arcsin
, \arcsine
, \arctan
, \arctangent
, \asec
, \asecant
, \asin
, \asine
, \atan
, \atangent
, \bmqty
, \bqty
, \Bqty
, \bra
, \braket
, \comm
, \commutator
, \cos
, \cosecant
, \cosh
, \cosine
, \cot
, \cotangent
, \coth
, \cp
, \cross
, \crossproduct
, \csc
, \csch
, \curl
, \dd
, \derivative
, \det
, \determinant
, \diagonalmatrix
, \diffd
, \differential
, \div
, \divergence
, \dmat
, \dotproduct
, \dv
, \dyad
, \erf
, \ev
, \eval
, \evaluated
, \exp
, \expectationvalue
, \exponential
, \expval
, \fderivative
, \fdv
, \flatfrac
, \functionalderivative
, \grad
, \gradient
, \gradientnabla
, \hypcosecant
, \hypcosine
, \hypcotangent
, \hypsecant
, \hypsine
, \hyptangent
, \identitymatrix
, \Im
, \imaginary
, \imat
, \innerproduct
, \ip
, \ket
, \ketbra
, \laplacian
, \ln
, \log
, \logarithm
, \matrixdeterminant
, \matrixel
, \matrixelement
, \matrixquantity
, \mdet
, \mel
, \mqty
, \naturallogarithm
, \norm
, \op
, \order
, \outerproduct
, \partialderivative
, \paulimatrix
, \pb
, \pderivative
, \pdv
, \pmat
, \pmqty
, \Pmqty
, \poissonbracket
, \pqty
, \Pr
, \principalvalue
, \Probability
, \pv
, \PV
, \qall
, \qand
, \qas
, \qassume
, \qc
, \qcc
, \qcomma
, \qelse
, \qeven
, \qfor
, \qgiven
, \qif
, \qin
, \qinteger
, \qlet
, \qodd
, \qor
, \qotherwise
, \qq
, \qqtext
, \qsince
, \qthen
, \qty
, \quantity
, \qunless
, \qusing
, \rank
, \Re
, \real
, \Res
, \Residue
, \sbmqty
, \sec
, \secant
, \sech
, \sin
, \sine
, \sinh
, \smallmatrixquantity
, \smdet
, \smqty
, \spmqty
, \sPmqty
, \svmqty
, \tan
, \tangent
, \tanh
, \tr
, \Tr
, \trace
, \Trace
, \va
, \var
, \variation
, \vb
, \vdot
, \vectorarrow
, \vectorbold
, \vectorunit
, \vmqty
, \vnabla
, \vqty
, \vu
, \xmat
, \xmatrix
, \zeromatrix
, \zmat
And the following environments:
smallmatrix
require¶
The require extension defines the nonstandard \require
macro
that allows you to load extensions from within a math expression in a
web page. For example:
\(\require{enclose} \enclose{circle}{x}\)
would load the enclose extension, making the following
\enclose
command available for use.
An extension only needs to be loaded once, and then it is available for all subsequent typeset expressions.
This extension is already loaded in all the components that
include the TeX input jax, other than input/texbase
. To load the
require extension explicitly (when using input/texbase
for
example), add '[tex]/require'
to the load
array of the
loader
block of your MathJax configuration, and add 'require'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/require']},
tex: {packages: {'[+]': ['require']}}
};
Since the require extension is included in the combined components that contain the TeX input jax, it may already be in the package list. In that case, if you want to disable it, you can remove it:
window.MathJax = {
tex: {packages: {'[]': ['require']}}
};
require Options¶
Adding the require extension to the packages
array defines a
require
subblock of the tex
configuration block with the
following values:
MathJax = {
tex: {
require: {
allow: {
base: false,
'allpackages': false
},
defaultAllow: true
}
};

allow: {...}
This subobject indicates which extensions can be loaded by
\require
. The keys are the package names, and the value istrue
to allow the extension to be loaded, andfalse
to disallow it. If an extension is not in the list, the default value is given bydefaultAllow
, described below.

defaultAllow: true
This is the value used for any extensions that are requested, but are not in the
allow
object described above. If set totrue
, any extension not listed inallow
will be allowed; iffalse
, only the ones listed inallow
(with valuetrue
) will be allowed.
setoptions¶
The setoptions extension implements a nonstandard \setOptions
macro that allows you to change the options for a TeX package, or for
the TeX input jax itself, from within a TeX expression.

setOptions[package]{options}
Sets the options for package to the ones given in options. Here, options is a collection of spaceseparated option names (to be set to
true
) or option=value declarations, where the given option will get the specified value. If the value contains spaces, it can be enclosed in braces, which will not become part of the value.
For example:
\[
\setOptions{tagSide=left}
E = mc^2 \tag{1}
\]
\[
\setOptions{tagSide=right}
e^{\pi 1} + 1 = 0 \tag{2}
\]
would typeset the first expression with its tag on the left, and the second (and subsequent) expressions with tags on the right.
To change a package setting, use the package name as an optional bracket argument:
\[
\setOptions[physics]{arrowdel=true}
\grad
\setOptions[physics]{arrowdel=false}
\]
Here the gradient symbol with have an arrow, but subsequent ones will not.
Note that any changes made by \setOptions
are global, so will
affect all the following expressions. If you want a local change,
you will need to set the value back to its original one explicitly.
Because changing the option settings can cause adverse consequences,
and so could be misused in a setting where users are provided the TeX
content for your site, the setoptions package is not autoloaded,
it does not appear in the list of all packages, and it can not be
loaded with \require{}
. You must include it in the package list
explicitly if you want to allow its use.
To load the setoptions extension, add '[tex]/setoptions'
to the
load
array of the loader
block of your MathJax configuration, and add
'setoptions'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/centernot']},
tex: {packages: {'[+]': ['centernot']}}
};
The require command with setoptions¶
If the require package is enabled, setoptions modifies
\require
to allow passing of options for the required package (and
makes the original \require
macro available as \Require
). So
the new syntax is:

require[options]{package}
where options is a list of options in the same format as used by
\setOptions
, and package
is the name of the extension to load.
This command is equivalent to:
\Require{package}\setOptions[package]{options}
meaning that the package is loaded and then its options are set.
For example:
\require[harrowsize=3em]{amscd}
would load the amscd extension and then set its harrowsize
option to 3em
.
Note that the same rules apply to which options can be set for which
package as those that govern \setOptions
itself.
setoptions Options¶
Adding the setoptions extension to the packages
array defines a
setoptions
subblock of the tex
configuration block with the
following values:
MathJax = {
tex: {
setoptions: {
filterPackage: SetOptionsUtil.filterPackage, // filter for whether a package can be configured
filterOption: SetOptionsUtil.filterOption, // filter for whether an option can be set
filterValue: SetOptionsUtil.filterValue, // filter for the value to assign to an option
allowPackageDefault: true, // default for allowing packages when not explicitly set in allowOptions
allowOptionsDefault: true, // default for allowing option that isn't explicitly set in allowOptions
allowOptions: { // list of packages to allow/disallow, and their options to allow/disallow
//
// toplevel tex items can be set, but not these ones
// (that leaves digits and the tagging options that can be set)
//
tex: {
FindTeX: false,
formatError: false,
package: false,
baseURL: false,
tags: false, // would require a new TeX input jax instance
maxBuffer: false,
maxMaxros: false,
macros: false,
environments: false
},
//
// These packages can't be configured at all
//
setoptions: false,
autoload: false,
require: false,
configmacros: false,
tagformat: false
}
}
}
};

filterPackage: SetOptionsUtil.filterPackage
This is a function that is called to determine if a package can have its options set or not. It is passed the TeX parser and the name of the extension as its arguments, and returns true if the package allows its options to be configured and false otherwise. The default is to first check that the named package exists, then check if the package is explicitly allowed by its entry in the
allowOptions
property being eithertrue
or a list of theallowOptions
property. The entry can either betrue
, allowing all options of the package to be set, or a list of the options that are allowed to be set. If the entry is explicitlyfalse
or theallowPackageDefault
option isfalse
, an error is issued. You can supply your own function to process the package names in another way if you wish.

filterOption: SetOptionsUtil.filterOption
This is a function that is called to determine whether an option can be set for a given package. It is passed the TeX parser, the package name, and the option name as its arguments, and returns true if that option can be set for that package, and false otherwise. The default is to check if the option is listed explicitly in the list of options for the given package in the
allowOptions
. If the value is explicitly false, or if it is not listed and theallowOptionDefault
is false, then produce an error. Otherwise check that the option actually exists for the package, and report an error if not, otherwise allow the option to be set. You can supply your own function to process the option names in another way if you wish.

filterValue: SetOptionsUtil.filterValue
This is a function that is called to check the value provided for a given option is allowed. It is passed the TeX parser, the package name, the option name, and the new option value as its arguments, and it returns the value to be used for the option. The default is simply to return the value it is given, but you can use this to alter the value, or to produce an error if the value is not valid.

allowPackageDefault: true
This indicates how to handle packages that are not listed explicitly in the
allowOptions
list. Iftrue
, packages that are not listed are allowed to have their options set. If the value isfalse
, only the packages that are listed astrue
or have explicit option lists can have their options set.

allowOptionsDefault: true
This indicates how to handle options that are not listed explicitly in the
allowOptions
list for a given package. Iftrue
, options that are not listed are allowed to be set, and iffalse
, only the options that are listed explicitly astrue
for the given package can have their options set.

allowOptions: {...}
This is a list of the packages that indicates whether their options can be set or not, and which options can be set. If a package name appears and is explicitly set to
false
, that package’s options can’t be set. If it istrue
andallowOptionsDefault
is true, then any of its options can be set. If it is an explicit list of options, then if the option is listed astrue
, it can be set, and iffalse
it can not. If an option is not listed, then the value ofallowOptionsDefault
is used to determine whether it can be set or not. If a package does not appear explicitly in the list, then the value ofallowPackageDefault
is used to determine if the package’s options can be set or not.You can include additional package names and their options in this list. The defaults are set to allow reasonable security without having to list every single option that can be set.
tagformat¶
The tagformat extension provides the ability to customize the format
of the equation tags and automatic equation numbers. You do this by
providing functions in the tagformat
object of the tex
block
of your MathJax configuration. The functions you can provide are
listed in the tagformat Options section.
To load the tagformat extension, add '[tex]/tagformat'
to the
load
array of the loader
block of your MathJax configuration,
and add 'tagformat'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/tagformat']},
tex: {packages: {'[+]': ['tagformat']}}
};
tagformat Options¶
Adding the tagformat extension to the packages
array adds a
tagformat
subobject to the tex
configuration block with the
following values:
tagformat: {
number: (n) => n.toString(),
tag: (tag) => '(' + tag + ')',
id: (id) => 'mjxeqn:' + id.replace(/\s/g, '_'),
url: (id, base) => base + '#' + encodeURIComponent(id),
}

number: function (n) {return n.toString()}
A function that tells MathJax what tag to use for equation number
n
. This could be used to have the equations labeled by a sequence of symbols rather than numbers, or to use section and subsection numbers instead.

tag: function (n) {return '(' + n + ')'}
A function that tells MathJax how to format an equation number for displaying as a tag for an equation. This is what appears in the margin of a tagged or numbered equation.

id: function (n) {return 'mjxeqn:' + n.replace(/\s/g, '_')}
A function that tells MathJax what ID to use as an anchor for the equation (so that it can be used in URL references).

url: function (id, base) {return base + '#' + encodeURIComponent(id)}
A function that takes an equation ID and base URL and returns the URL to link to it. The
base
value is taken from the baseURL value, so that links can be make within a page even if it has a<base>
element that sets the base URL for the page to a different location.
Example: Section Numbering¶
This example shows one way to provide section numbers for the
automatic equation numbers generated when the tags
option in the
tex
configuration block is set to 'ams'
or 'all'
.
MathJax = {
section: 1,
tex: {
tagformat: {
number: (n) => MathJax.config.section + '.' + n,
id: (tag) => 'eqnid:' + tag
}
},
startup: {
ready() {
MathJax.startup.defaultReady();
MathJax.startup.input[0].preFilters.add(({math}) => {
if (math.inputData.recompile) {
MathJax.config.section = math.inputData.recompile.section;
}
});
MathJax.startup.input[0].postFilters.add(({math}) => {
if (math.inputData.recompile) {
math.inputData.recompile.section = MathJax.config.section;
}
});
}
}
};
This arranges for automatic equation numbers to be of the form
1.n
, and uses ids of the form eqnid:1.n
as the id
attribute of the tags within the web page. It also sets up pre and
postfilters for the TeX input jax that arrange for the section number
to be properly handled for automatically numbered equations that
contain forward references to later expressions. This example uses
the modern function notation (using =>
), but you could also use
function (n) {return ...}
.
You can adjust the section number using JavaScript by setting the
MathJax.config.section
variable. It is also possible to create
TeX macros for controlling the section number. Here is one
possibility:
MathJax = {
startup: {
ready() {
const Configuration = MathJax._.input.tex.Configuration.Configuration;
const CommandMap = MathJax._.input.tex.SymbolMap.CommandMap;
new CommandMap('sections', {
nextSection: 'NextSection',
setSection: 'SetSection',
}, {
NextSection(parser, name) {
MathJax.config.section++;
parser.tags.counter = parser.tags.allCounter = 0;
},
SetSection(parser, name) {
const n = parser.GetArgument(name);
MathJax.config.section = parseInt(n);
}
});
Configuration.create(
'sections', {handler: {macro: ['sections']}}
);
MathJax.startup.defaultReady();
}
}
};
Of course, you will want to merge this configuraiton in with the rest of your configuration options.
This makes two new macros available: \nextSection
, which
increments the section counter, and \setSection{n}
, which sets the
section number to n
. Note that these must be issued within math
delimiters in order for MathJax to process them. In order to prevent
them from producing any output in your page, you could enclose them
within a hidden element. For example,
<span style="display: hidden">\(\nextSection\)</span>
or something similar.
textcomp¶
The textcomp extension implements the old textcomp
style package from
LaTeX. The macros of the package are now part of LaTeX’s base package. The
textcomp extension provides a number of text macros that can be used in math
mode as well. See the CTAN page for
more information and documentation of textcomp.
This package is not autoloaded, so you must request it explicitly if you want to
use it. To load the textcomp extension, add '[tex]/textcomp'
to the
load
array of the loader
block of your MathJax configuration, and add
'textcomp'
to the packages
array of the tex
block. The macros
provided in textcomp can be used equally in math and text mode. In order to
make them available in text mode they have to be explicitly added to the
packages of the textmacros extension.
window.MathJax = {
loader: {load: ['[tex]/textmacros', '[tex]/textcomp']},
tex: {packages: {'[+]': ['textmacros']}}
textmacros: {packages: {'[+]': ['textcomp']}}
};
Alternatively, use \require{textcomp}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
textcomp Commands¶
The textcomp extension implements the following macros:
\textacutedbl
, \textasciiacute
, \textasciibreve
, \textasciicaron
, \textasciicircum
, \textasciidieresis
, \textasciimacron
, \textasciitilde
, \textasteriskcentered
, \textbackslash
, \textbaht
, \textbar
, \textbardbl
, \textbigcircle
, \textblank
, \textborn
, \textbraceleft
, \textbraceright
, \textbrokenbar
, \textbullet
, \textcelsius
, \textcent
, \textcentoldstyle
, \textcircledP
, \textcolonmonetary
, \textcompwordmark
, \textcopyleft
, \textcopyright
, \textcurrency
, \textdagger
, \textdaggerdbl
, \textdegree
, \textdied
, \textdiscount
, \textdiv
, \textdivorced
, \textdollar
, \textdollaroldstyle
, \textdong
, \textdownarrow
, \texteightoldstyle
, \textellipsis
, \textemdash
, \textendash
, \textestimated
, \texteuro
, \textexclamdown
, \textfiveoldstyle
, \textflorin
, \textfouroldstyle
, \textfractionsolidus
, \textgravedbl
, \textgreater
, \textguarani
, \textinterrobang
, \textinterrobangdown
, \textlangle
, \textlbrackdbl
, \textleftarrow
, \textless
, \textlira
, \textlnot
, \textlquill
, \textmarried
, \textmho
, \textminus
, \textmu
, \textmusicalnote
, \textnaira
, \textnineoldstyle
, \textnumero
, \textohm
, \textonehalf
, \textoneoldstyle
, \textonequarter
, \textonesuperior
, \textopenbullet
, \textordfeminine
, \textordmasculine
, \textparagraph
, \textperiodcentered
, \textpertenthousand
, \textperthousand
, \textpeso
, \textpm
, \textquestiondown
, \textquotedblleft
, \textquotedblright
, \textquoteleft
, \textquoteright
, \textrangle
, \textrbrackdbl
, \textrecipe
, \textreferencemark
, \textregistered
, \textrightarrow
, \textrquill
, \textsection
, \textservicemark
, \textsevenoldstyle
, \textsixoldstyle
, \textsterling
, \textsurd
, \textthreeoldstyle
, \textthreequarters
, \textthreesuperior
, \texttildelow
, \texttimes
, \texttrademark
, \texttwooldstyle
, \texttwosuperior
, \textunderscore
, \textuparrow
, \textvisiblespace
, \textwon
, \textyen
, \textzerooldstyle
textmacros¶
The textmacros extension adds the ability to process some textmode
macros within \text{}
and other macros that produce textmode
material. See the Differences from Actual TeX section for how textmode is
handled without this extension.
This extension is not loaded automatically, and can’t be loaded via
the autoload extension. To load the textmacros extension, add
'[tex]/textmacros'
to the load
array of the loader
block
of your MathJax configuration, and add 'textmacros'
to the
packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/textmacros']},
tex: {packages: {'[+]': ['textmacros']}}
};
Alternatively, use \require{textmacros}
in a TeX expression to load it
dynamically from within the math on the page, if the require
package is loaded.
Available Macros:¶
The macros available in text mode with this extension are listed
below. In addition, any macro that is defined via \def
or
\newcommand
or in the macros
section of the tex
configuration block will also be processed if they only contain macros
from the list below.
Additional Special Characters¶
~ 
nonbreaking space 
`  open quote (use two for double quote) 
' 
close quote (use two for double quote) 
Math Mode Delimiters¶
$ 
start/end math mode 
\( 
start math mode 
\) 
end math mode 
Quoted Special Characters¶
\$ 
literal dollar sign 
\_ 
literal underscore 
\% 
literal percent 
\{ 
literal open brace 
\} 
literal close brace 
\ (backslashspace) 
literal space 
\& 
literal ampersand 
\# 
literal hash mark 
\\ 
literal backslash 
Text Accents¶
\' 
acute accent 
\` 
grave accent 
\^ 
circumflex accent 
\" 
umlaut accent 
\~ 
tilde accent 
\= 
macron accent 
\. 
over dot accent 
\u 
breve accent 
\v 
caron accent 
Font Control¶
\emph 
emphasized text 
\rm 
roman text 
\oldstyle 
oldstyle numerals 
\cal 
calligraphic text 
\it 
italic text 
\bf 
bold text 
\scr 
script text 
\frak 
Fraktur text 
\sf 
sansserif text 
\tt 
typewriter text 
\Bbb 
blackboardbold text 
\textrm 
roman text 
\textit 
italic text 
\textbf 
bold text 
\textsf 
sansserif text 
\texttt 
typewriter text 
Size Control¶
\tiny 
very tiny size 
\Tiny 
tiny size 
\scriptsize 
size of super and subscripts 
\small 
small size 
\normalsize 
standard size 
\large 
large size 
\Large 
larger sizse 
\LARGE 
very large size 
\huge 
even larger size 
\Huge 
largest size 
Special Characters¶
\dagger 
† 
\ddagger 
‡ 
\S 
§ 
Spacing Commands¶
\, 
thin space 
\: 
medium space 
\> 
medium space 
\; 
thick space 
\! 
negative thin space 
\enspace 
enspace 
\quad 
quad space 
\qquad 
double quad space 
\thinspace 
thin space 
\negthinspace 
negative thin space 
\hskip 
horizontal skip (by following amount) 
\hspace 
horizontal space (of a given size) 
\kern 
kern (by a given size) 
\rule 
line of a given width and height 
\Rule 
box with given dimensions 
\Space 
space with given dimensions 
Color Commands¶
\color 
set text color 
\textcolor 
set text color 
\colorbox 
make colored box 
\fcolorbox 
make framed colored box 
HTML Commands¶
\href 
make hyperlink 
\style 
specify CSS styles 
\class 
specify CSS class 
\cssId 
specify CSS id 
\unicode 
character from unicode value 
Equation Numbers¶
\ref 
cite a labeled equation 
\eqref 
cite a labeled equation with parentheses 
Additional Packages¶
You can configure the textmacros extension to use additional packages, just as you can specify additional math TeX packages. Normally, these should be pckages designed for text mode, but it is possible to load some of the regular TeX packages as text macros. For example
MathJax = {
loader: {load: ['[tex]/textmacros', '[tex]/bbox']},
tex: {
packages: {'[+]': {'textmacros'}},
textmacros: {
packages: {'[+]': ['bbox']}
}
}
}
would make the bbox extension available in text mode, so
you could use \bbox
inside \text{}
, for example. Not all
mathmode extensions are approrpriate for textmode, but some can be
usefully employed in text mode.
unicode¶
The unicode extension implements a (nonstandard) \unicode{}
macro that allows arbitrary unicode code points to be entered in your
mathematics. You can specify the height and depth of the character
(the width is determined by the browser), and the default font from
which to take the character.
Examples:
\unicode{65} % the character 'A'
\unicode{x41} % the character 'A'
\unicode[.55,0.05]{x22D6} % lessthan with dot, with height .55em and depth 0.05em
\unicode[.55,0.05][Geramond]{x22D6} % same taken from Geramond font
\unicode[Garamond]{x22D6} % same, but with default height, depth of .8em,.2em
Once a size and font are provided for a given unicode point, they need
not be specified again in subsequent \unicode{}
calls for that
character.
The result of \unicode{...}
will have TeX class ORD (i.e., it
will act like a variable). Use \mathbin{...}
, \mathrel{...}
,
etc., to specify a different class.
Note that a font list can be given in the \unicode{}
macro. If
not is provided, MathJax will use its own fonts, if possible, and then
the default font list for unknown characters if not.
Note
In version 2, you could configure the default font to be used for
\unicode
characters if one wasn’t given explicitly. This has
not been implemented in version 3.
This extension is loaded automatically when the autoload extension
is used. To load the unicode extension explicitly, add
'[tex]/unicode'
to the load
array of the loader
block of
your MathJax configuration, and add 'unicode'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/unicode']},
tex: {packages: {'[+]': ['unicode']}}
};
Alternatively, use \require{unicode}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
upgreek¶
The upgreek extension implements the upgreek
style package from LaTeX. It
provides upright Greek characters for both lower and upper cases. See the CTAN
page for more information and
documentation of upgreek.
Note, that the extension does not implement the font selection options from the LaTeX package.
This package is not autoloaded, so you must request it explicitly if you want to use it.
To load the upgreek extension, add '[tex]/upgreek'
to the load
array of the loader
block of your
MathJax configuration, and add 'upgreek'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/upgreek']},
tex: {packages: {'[+]': ['upgreek']}}
};
You can configure the autoload extension to load upgreek via
window.MathJax = {
tex: {
autoload: {
upgreek: ['upalpha', 'upbeta', 'upchi', 'updelta', 'Updelta', 'upepsilon',
'upeta', 'upgamma', 'Upgamma', 'upiota', 'upkappa', 'uplambda',
'Uplambda', 'upmu', 'upnu', 'upomega', 'Upomega', 'upomicron',
'upphi', 'Upphi', 'uppi', 'Uppi', 'uppsi', 'Uppsi', 'uprho',
'upsigma', 'Upsigma', 'uptau', 'uptheta', 'Uptheta', 'upupsilon',
'Upupsilon', 'upvarepsilon', 'upvarphi', 'upvarpi', 'upvarrho',
'upvarsigma', 'upvartheta', 'upxi', 'Upxi', 'upzeta']
}
}
};
Alternatively, use \require{upgreek}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
upgreek Commands¶
The upgreek extension implements the following macros:
\upalpha
, \upbeta
, \upchi
, \updelta
, \Updelta
, \upepsilon
, \upeta
, \upgamma
, \Upgamma
, \upiota
, \upkappa
, \uplambda
, \Uplambda
, \upmu
, \upnu
, \upomega
, \Upomega
, \upomicron
, \upphi
, \Upphi
, \uppi
, \Uppi
, \uppsi
, \Uppsi
, \uprho
, \upsigma
, \Upsigma
, \uptau
, \uptheta
, \Uptheta
, \upupsilon
, \Upupsilon
, \upvarepsilon
, \upvarphi
, \upvarpi
, \upvarrho
, \upvarsigma
, \upvartheta
, \upxi
, \Upxi
, \upzeta
verb¶
The verb extension defines the \verb
LaTeX macro that typesets
its argument “verbatim” (without further processing) in a monospaced
(typewriter) font. The first character after the \verb
command is
used as a delimiter for the argument, which is everything up to the
next copy of the delimiter character). E.g.
\verb\sqrt{x}
will typeset \sqrt{x}
as a literal string.
Note that, due to how MathJax locates math strings within the
document, the argument to \verb
must have balanced braces, so
\verb{
is not valid in a web page (use \mathtt{\{}
instead).
If you are passing TeX strings to MathJax.tex2svg()
or
MathJax.tex2chtml()
, however, braces don’t have to be balanced. So
const html = MathJax.tex2chtml('\\verb{');
is valid.
This extension is loaded automatically when the autoload extension
is used. To load the verb extension explicitly (when using
input/texbase
for example), add '[tex]/verb'
to the
load
array of the loader
block of your MathJax configuration,
and add 'verb'
to the packages
array of the tex
block.
window.MathJax = {
loader: {load: ['[tex]/verb']},
tex: {packages: {'[+]': ['verb']}}
};
Alternatively, use \require{verb}
in a TeX expression to load it
dynamically from within the math on the page, if the require
extension is loaded.
These extensions have not yet been ported to version 3:
autoloadall¶
The autoloadall extension has been replaced by the autoload extension, which is more easily configurable.
begingroup¶
The begingroup extension has not yet been translated to version 3, so currently it is not available. It should be included in a future release of MathJax.
mediawikitexvc¶
The mediawikitexvc extension predefines macros that match the behavior of the MediaWiki Math Extension.
This extension has not yet been translated to version 3, so currently it is not available. It should be included in a future release of MathJax.
See the A Custom Extension section for how to create your own TeX extension.
Supported TeX/LaTeX commands¶
This is a long list of the TeX macros supported by MathJax. If the macro is defined in an extension, the name of the extension follows the macro name. If the extension is in brackets, the extension will be loaded automatically when the macro or environment is first used.
More complete details about how to use these macros, with examples and explanations, is available at Carol Fisher’s TeX Commands Available in MathJax page. (These were written for MathJax v2, but most of the information is still correct for v3.)
In the following tables, the first column lists the macro (or
character, or environment), and the second column indicates which
package(s) defines the macro. If none is listed, then it is in the
base package. If the package name is in bold, then it is preloaded by
the components that include the TeX input jax (except for
input/texbase
, which only includes the base package). If the
package name is in italics, then the package is not autoloaded by
the autoload extension.
Note that most macros are not processed inside textmode material
(such as that within \text{}
and other similar macros). The
textmacros extension makes additional macros available in
text mode, as listed in the documentation for that extention.
Symbols¶
_ 

. 

' 

’ 

( 

) 
base, physics 
[ 

] 
base, physics 
{ 

} 

@ 
amscd 
/ 

\ (backslashspace) 

\_ 

\, 

\; 

\: 
base, mathtools 
\! 

\{ 

\} 

\\ 

\& 

\# 

\% 

\> 

\ 
base, braket 
\$ 

& 
base, cases 
# 

% 

^ 

< 

> 

 
base, braket, physics 
~ 
A¶
\above 

\abovewithdelims 

\Aboxed 
mathtools 
\abs 
physics 
\absolutevalue 
physics 
\acomm 
physics 
\acos 
physics 
\acosecant 
physics 
\acosine 
physics 
\acot 
physics 
\acotangent 
physics 
\acsc 
physics 
\acute 

\adjustlimits 
mathtools 
\admat 
physics 
\aleph 

\alpha 

\alwaysDashedLine 
bussproofs 
\alwaysNoLine 
bussproofs 
\alwaysRootAtBottom 
bussproofs 
\alwaysRootAtTop 
bussproofs 
\alwaysSingleLine 
bussproofs 
\alwaysSolidLine 
bussproofs 
\amalg 

\And 

\angle 

\anticommutator 
physics 
\antidiagonalmatrix 
physics 
\approx 

\approxeq 
ams 
\arccos 
base, physics 
\arccosecant 
physics 
\arccosine 
physics 
\arccot 
physics 
\arccotangent 
physics 
\arccsc 
physics 
\arcsec 
physics 
\arcsecant 
physics 
\arcsin 
base, physics 
\arcsine 
physics 
\arctan 
base, physics 
\arctangent 
physics 
\arg 

\array 

\ArrowBetweenLines 
mathtools 
\arrowvert 

\Arrowvert 

\asec 
physics 
\asecant 
physics 
\asin 
physics 
\asine 
physics 
\ast 

\asymp 

\atan 
physics 
\atangent 
physics 
\atop 

\atopwithdelims 

\AXC 
bussproofs 
\Axiom 
bussproofs 
\AxiomC 
bussproofs 
B¶
\backepsilon 
ams 
\backprime 
ams 
\backsim 
ams 
\backsimeq 
ams 
\backslash 

\bar 

\barwedge 
ams 
\Bbb 

\Bbbk 
ams 
\bbFont 

\bbox 
bbox 
\bcancel 
cancel 
\because 
ams 
\begin 

\beta 

\beth 
ams 
\between 
ams 
\bf 

\BIC 
bussproofs 
\big 

\Big 

\bigcap 

\bigcirc 

\bigcup 

\bigg 

\Bigg 

\biggl 

\Biggl 

\biggm 

\Biggm 

\biggr 

\Biggr 

\bigl 

\Bigl 

\bigm 

\Bigm 

\bigodot 

\bigoplus 

\bigotimes 

\bigr 

\Bigr 

\bigsqcup 

\bigstar 
ams 
\bigtimes 
mathtools 
\bigtriangledown 

\bigtriangleup 

\biguplus 

\bigvee 

\bigwedge 

\BinaryInf 
bussproofs 
\BinaryInfC 
bussproofs 
\binom 
ams 
\blacklozenge 
ams 
\blacksquare 
ams 
\blacktriangle 
ams 
\blacktriangledown 
ams 
\blacktriangleleft 
ams 
\blacktriangleright 
ams 
\bmod 

\bmqty 
physics 
\boldsymbol 
boldsymbol 
\bot 

\bowtie 

\Box 
ams 
\boxdot 
ams 
\boxed 
base, ams 
\boxminus 
ams 
\boxplus 
ams 
\boxtimes 
ams 
\bqty 
physics 
\Bqty 
physics 
\bra 
braket, physics 
\Bra 
braket 
\brace 

\bracevert 

\brack 

\braket 
braket, physics 
\Braket 
braket 
\breve 

\buildrel 

\bullet 

\bumpeq 
ams 
\Bumpeq 
ams 
C¶
\cal 

\cancel 
cancel 
\cancelto 
cancel 
\cap 

\Cap 
ams 
\cases 

\cdot 

\cdotp 

\cdots 

\ce 
mhchem 
\cellcolor 
colortbl 
\celsius 
gensymb 
\centercolon 
mathtools 
\centerdot 
ams 
\centernot 
centernot 
\centerOver 
centernot 
\cfrac 
ams 
\check 

\checkmark 
ams 
\chi 

\choose 

\circ 

\circeq 
ams 
\circlearrowleft 
ams 
\circlearrowright 
ams 
\circledast 
ams 
\circledcirc 
ams 
\circleddash 
ams 
\circledR 
ams 
\circledS 
ams 
\clap 
mathtools 
\class 
html 
\clubsuit 

\colon 

\colonapprox 
mathtools 
\Colonapprox 
mathtools 
\coloneq 
mathtools 
\Coloneq 
mathtools 
\coloneqq 
mathtools 
\Coloneqq 
mathtools 
\colonsim 
mathtools 
\Colonsim 
mathtools 
\color 
color, colorv2 
\colorbox 
color 
\columncolor 
colortbl 
\comm 
physics 
\commutator 
physics 
\complement 
ams 
\cong 

\coprod 

\cos 
base, physics 
\cosecant 
physics 
\cosh 
base, physics 
\cosine 
physics 
\cot 
base, physics 
\cotangent 
physics 
\coth 
base, physics 
\cp 
physics 
\cr 

\cramped 
mathtools 
\crampedclap 
mathtools 
\crampedllap 
mathtools 
\crampedrlap 
mathtools 
\crampedsubstack 
mathtools 
\cross 
physics 
\crossproduct 
physics 
\csc 
base, physics 
\csch 
physics 
\cssId 
html 
\cup 

\Cup 
ams 
\curl 
physics 
\curlyeqprec 
ams 
\curlyeqsucc 
ams 
\curlyvee 
ams 
\curlywedge 
ams 
\curvearrowleft 
ams 
\curvearrowright 
ams 
D¶
\dagger 

\daleth 
ams 
\dashedLine 
bussproofs 
\dashleftarrow 
ams 
\dashrightarrow 
ams 
\dashv 

\dbinom 
ams 
\dblcolon 
mathtools 
\dd 
physics 
\ddagger 

\ddddot 
ams 
\dddot 
ams 
\ddot 

\ddots 

\DeclareMathOperator 
ams 
\DeclarePairedDelimiters 
mathtools 
\DeclarePairedDelimitersX 
mathtools 
\DeclarePairedDelimitersXPP 
mathtools 
\def 
newcommand 
\definecolor 
color 
\deg 

\degree 
gensymb 
\delta 

\Delta 

\derivative 
physics 
\det 
base, physics 
\determinant 
physics 
\dfrac 
ams 
\diagdown 
ams 
\diagonalmatrix 
physics 
\diagup 
ams 
\diamond 

\Diamond 
ams 
\diamondsuit 

\diffd 
physics 
\differential 
physics 
\digamma 
ams 
\dim 

\displaylines 

\displaystyle 

\div 
base, physics 
\divergence 
physics 
\divideontimes 
ams 
\divsymbol 

\dmat 
physics 
\dot 

\doteq 

\Doteq 
ams 
\doteqdot 
ams 
\dotplus 
ams 
\dotproduct 
physics 
\dots 

\dotsb 

\dotsc 

\dotsi 

\dotsm 

\dotso 

\doublebarwedge 
ams 
\doublecap 
ams 
\doublecup 
ams 
\downarrow 

\Downarrow 

\downdownarrows 
ams 
\downharpoonleft 
ams 
\downharpoonright 
ams 
\dv 
physics 
\dyad 
physics 
E¶
\ell 

\empheqbigl 
empheq 
\empheqbiglangle 
empheq 
\empheqbiglbrace 
empheq 
\empheqbiglbrack 
empheq 
\empheqbiglceil 
empheq 
\empheqbiglfloor 
empheq 
\empheqbiglparen 
empheq 
\empheqbiglvert 
empheq 
\empheqbiglVert 
empheq 
\empheqbigr 
empheq 
\empheqbigrangle 
empheq 
\empheqbigrbrace 
empheq 
\empheqbigrbrack 
empheq 
\empheqbigrceil 
empheq 
\empheqbigrfloor 
empheq 
\empheqbigrparen 
empheq 
\empheqbigrvert 
empheq 
\empheqbigrVert 
empheq 
\empheql 
empheq 
\empheqlangle 
empheq 
\empheqlbrace 
empheq 
\empheqlbrack 
empheq 
\empheqlceil 
empheq 
\empheqlfloor 
empheq 
\empheqlparen 
empheq 
\empheqlvert 
empheq 
\empheqlVert 
empheq 
\empheqr 
empheq 
\empheqrangle 
empheq 
\empheqrbrace 
empheq 
\empheqrbrack 
empheq 
\empheqrceil 
empheq 
\empheqrfloor 
empheq 
\empheqrparen 
empheq 
\empheqrvert 
empheq 
\empheqrVert 
empheq 
\emptyset 

\enclose 
enclose 
\end 

\enspace 

\epsilon 

\eqalign 

\eqalignno 

\eqcirc 
ams 
\eqcolon 
mathtools 
\Eqcolon 
mathtools 
\eqqcolon 
mathtools 
\Eqqcolon 
mathtools 
\eqref 
ams 
\eqsim 
ams 
\eqslantgtr 
ams 
\eqslantless 
ams 
\equiv 

\erf 
physics 
\eta 

\eth 
ams 
\ev 
physics 
\eval 
physics 
\evaluated 
physics 
\exists 

\exp 
base, physics 
\expectationvalue 
physics 
\exponential 
physics 
\expval 
physics 
F¶
\fallingdotseq 
ams 
\fbox 

\fCenter 
bussproofs 
\fcolorbox 
color 
\fderivative 
physics 
\fdv 
physics 
\Finv 
ams 
\flat 

\flatfrac 
physics 
\forall 

\frac 
base, ams 
\frak 

\framebox 

\frown 

\functionalderivative 
physics 
G¶
\Game 
ams 
\gamma 

\Gamma 

\gcd 

\ge 

\genfrac 
ams 
\geq 

\geqq 
ams 
\geqslant 
ams 
\gets 

\gg 

\ggg 
ams 
\gggtr 
ams 
\gimel 
ams 
\gnapprox 
ams 
\gneq 
ams 
\gneqq 
ams 
\gnsim 
ams 
\grad 
physics 
\gradient 
physics 
\gradientnabla 
physics 
\grave 

\gt 

\gtrapprox 
ams 
\gtrdot 
ams 
\gtreqless 
ams 
\gtreqqless 
ams 
\gtrless 
ams 
\gtrsim 
ams 
\gvertneqq 
ams 
H¶
\hat 

\hbar 

\hbox 

\hdashline 

\heartsuit 

\hfil 

\hfill 

\hfilll 

\hline 

\hom 

\hookleftarrow 

\hookrightarrow 

\hphantom 

\href 
html 
\hskip 

\hslash 
ams 
\hspace 

\huge 

\Huge 

\hypcosecant 
physics 
\hypcosine 
physics 
\hypcotangent 
physics 
\hypsecant 
physics 
\hypsine 
physics 
\hyptangent 
physics 
I¶
\identitymatrix 
physics 
\idotsint 
ams 
\iff 

\iiiint 
ams 
\iiint 

\iint 

\Im 
base, physics 
\imaginary 
physics 
\imat 
physics 
\imath 

\impliedby 
ams 
\implies 
ams 
\in 

\inf 

\infty 

\injlim 
ams 
\innerproduct 
physics 
\int 

\intercal 
ams 
\intop 

\iota 

\ip 
physics 
\it 
J¶
\jmath 

\Join 
ams 
K¶
\kappa 

\ker 

\kern 

\ket 
braket, physics 
\Ket 
braket 
\ketbra 
braket, physics 
\Ketbra 
braket 
L¶
\label 

\lambda 

\Lambda 

\land 

\langle 

\laplacian 
physics 
\large 

\Large 

\LARGE 

\LaTeX 

\lbrace 

\lbrack 

\lceil 

\ldotp 

\ldots 

\le 

\leadsto 
ams 
\left 

\Leftarrow 

\leftarrow 

\leftarrowtail 
ams 
\leftharpoondown 

\leftharpoonup 

\LeftLabel 
bussproofs 
\leftleftarrows 
ams 
\Leftrightarrow 

\leftrightarrow 

\leftrightarrows 
ams 
\leftrightharpoons 
ams 
\leftrightsquigarrow 
ams 
\leftroot 

\leftthreetimes 
ams 
\leq 

\leqalignno 

\leqq 
ams 
\leqslant 
ams 
\lessapprox 
ams 
\lessdot 
ams 
\lesseqgtr 
ams 
\lesseqqgtr 
ams 
\lessgtr 
ams 
\lesssim 
ams 
\let 
newcommand 
\lfloor 

\lg 

\lgroup 

\lhd 
ams 
\lim 

\liminf 

\limits 

\limsup 

\ll 

\LL 
bussproofs 
\llap 

\llcorner 
ams 
\Lleftarrow 
ams 
\lll 
ams 
\llless 
ams 
\lmoustache 

\ln 
base, physics 
\lnapprox 
ams 
\lneq 
ams 
\lneqq 
ams 
\lnot 

\lnsim 
ams 
\log 
base, physics 
\logarithm 
physics 
\longleftarrow 

\Longleftarrow 

\Longleftrightarrow 

\longleftrightarrow 

\longleftrightarrows 
mhchem 
\longLeftrightharpoons 
mhchem 
\longmapsto 

\longrightarrow 

\Longrightarrow 

\longrightleftharpoons 
mhchem 
\longRightleftharpoons 
mhchem 
\looparrowleft 
ams 
\looparrowright 
ams 
\lor 

\lower 

\lozenge 
ams 
\lparen 
mathtools 
\lrcorner 
ams 
\Lsh 
ams 
\lt 

\ltimes 
ams 
\lvert 
ams 
\lVert 
ams 
\lvertneqq 
ams 
M¶
\maltese 
ams 
\mapsto 

\mathbb 

\mathbf 

\mathbfcal 

\mathbffrak 

\mathbfit 

\mathbfscr 

\mathbfsf 

\mathbfsfit 

\mathbfsfup 

\mathbfup 

\mathbin 

\mathcal 

\mathchoice 

\mathclap 
mathtools 
\mathclose 

\mathfrak 

\mathinner 

\mathit 

\mathllap 
mathtools 
\mathmakebox 
mathtools 
\mathmbox 
mathtools 
\mathnormal 

\mathop 

\mathopen 

\mathord 

\mathpunct 

\mathrel 

\mathring 
ams 
\mathrlap 
mathtools 
\mathrm 

\mathscr 

\mathsf 

\mathsfit 

\mathsfup 

\mathstrut 

\mathtip 
action 
\mathtoolsset 
mathtools 
\mathtt 

\mathup 

\matrix 

\matrixdeterminant 
physics 
\matrixel 
physics 
\matrixelement 
physics 
\matrixquantity 
physics 
\max 

\mbox 

\mdet 
physics 
\measuredangle 
ams 
\mel 
physics 
\mho 
ams 
\micro 
gensymb 
\mid 

\middle 

\min 

\minCDarrowheight 
amscd 
\minCDarrowwidth 
amscd 
\mit 

\mkern 

\mmlToken 

\mod 

\models 

\MoveEqLeft 
mathtools 
\moveleft 

\moveright 

\mp 

\mqty 
physics 
\mskip 

\mspace 

\MTFlushSpaceAbove 
mathtools 
\MTFlushSpaceBelow 
mathtools 
\MTThinColon 
mathtools 
\mu 

\multimap 
ams 
N¶
\nabla 

\natural 

\naturallogarithm 
physics 
\ncong 
ams 
\ndownarrow 
mathtools 
\ne 

\nearrow 

\neg 

\negmedspace 
ams 
\negthickspace 
ams 
\negthinspace 

\neq 

\newcommand 
newcommand 
\newenvironment 
newcommand 
\Newextarrow 
extpfeil 
\newline 

\newtagform 
mathtools 
\nexists 
ams 
\ngeq 
ams 
\ngeqq 
ams 
\ngeqslant 
ams 
\ngtr 
ams 
\ni 

\nleftarrow 
ams 
\nLeftarrow 
ams 
\nleftrightarrow 
ams 
\nLeftrightarrow 
ams 
\nleq 
ams 
\nleqq 
ams 
\nleqslant 
ams 
\nless 
ams 
\nmid 
ams 
\nobreakspace 
ams 
\nolimits 

\noLine 
bussproofs 
\nonscript 

\nonumber 

\norm 
physics 
\normalsize 

\not 

\notag 
ams 
\notChar 

\notin 

\nparallel 
ams 
\nprec 
ams 
\npreceq 
ams 
\nrightarrow 
ams 
\nRightarrow 
ams 
\nshortmid 
ams 
\nshortparallel 
ams 
\nsim 
ams 
\nsubseteq 
ams 
\nsubseteqq 
ams 
\nsucc 
ams 
\nsucceq 
ams 
\nsupseteq 
ams 
\nsupseteqq 
ams 
\ntriangleleft 
ams 
\ntrianglelefteq 
ams 
\ntriangleright 
ams 
\ntrianglerighteq 
ams 
\nu 

\nuparrow 
mathtools 
\nvdash 
ams 
\nvDash 
ams 
\nVdash 
ams 
\nVDash 
ams 
\nwarrow 
O¶
\odot 

\ohm 
gensymb 
\oint 

\oldstyle 

\omega 

\Omega 

\omicron 

\ominus 

\op 
physics 
\operatorname 
ams 
\oplus 

\order 
physics 
\ordinarycolon 
mathtools 
\oslash 

\otimes 

\outerproduct 
physics 
\over 

\overbrace 

\overbracket 
mathtools 
\overleftarrow 

\overleftrightarrow 

\overline 

\overparen 

\overrightarrow 

\overset 

\overunderset 

\overwithdelims 

\owns 
P¶
\parallel 

\partial 

\partialderivative 
physics 
\paulimatrix 
physics 
\pb 
physics 
\pderivative 
physics 
\pdv 
physics 
\perp 

\perthousand 
gensymb 
\phantom 

\phi 

\Phi 

\pi 

\Pi 

\pitchfork 
ams 
\pm 

\pmat 
physics 
\pmatrix 

\pmb 

\pmod 

\pmqty 
physics 
\Pmqty 
physics 
\pod 

\poissonbracket 
physics 
\pqty 
physics 
\Pr 
base, physics 
\prec 

\precapprox 
ams 
\preccurlyeq 
ams 
\preceq 

\precnapprox 
ams 
\precneqq 
ams 
\precnsim 
ams 
\precsim 
ams 
\prescript 
mathtools 
\prime 

\principalvalue 
physics 
\Probability 
physics 
\prod 

\projlim 
ams 
\propto 

\psi 

\Psi 

\pu 
mhchem 
\pv 
physics 
\PV 
physics 
Q¶
\qall 
physics 
\qand 
physics 
\qas 
physics 
\qassume 
physics 
\qc 
physics 
\qcc 
physics 
\qcomma 
physics 
\qelse 
physics 
\qeven 
physics 
\qfor 
physics 
\qgiven 
physics 
\qif 
physics 
\qin 
physics 
\qinteger 
physics 
\qlet 
physics 
\qodd 
physics 
\qor 
physics 
\qotherwise 
physics 
\qq 
physics 
\qqtext 
physics 
\qquad 

\qsince 
physics 
\qthen 
physics 
\qty 
physics 
\quad 

\quantity 
physics 
\QuaternaryInf 
bussproofs 
\QuaternaryInfC 
bussproofs 
\QuinaryInf 
bussproofs 
\QuinaryInfC 
bussproofs 
\qunless 
physics 
\qusing 
physics 
R¶
\raise 

\rangle 

\rank 
physics 
\rbrace 

\rbrack 

\rceil 

\Re 
base, physics 
\real 
physics 
\ref 

\refeq 
mathtools 
\renewcommand 
newcommand 
\renewenvironment 
newcommand 
\renewtagform 
mathtools 
\Res 
physics 
\Residue 
physics 
\restriction 
ams 
\rfloor 

\rgroup 

\rhd 
ams 
\rho 

\right 

\Rightarrow 

\rightarrow 

\rightarrowtail 
ams 
\rightharpoondown 

\rightharpoonup 

\RightLabel 
bussproofs 
\rightleftarrows 
ams 
\rightleftharpoons 
base, ams 
\rightrightarrows 
ams 
\rightsquigarrow 
ams 
\rightthreetimes 
ams 
\risingdotseq 
ams 
\RL 
bussproofs 
\rlap 

\rm 

\rmoustache 

\root 

\rootAtBottom 
bussproofs 
\rootAtTop 
bussproofs 
\rowcolor 
colortbl 
\rparen 
mathtools 
\Rrightarrow 
ams 
\Rsh 
ams 
\rtimes 
ams 
\rule 

\Rule 

\rvert 
ams 
\rVert 
ams 
S¶
\S 

\sbmqty 
physics 
\scr 

\scriptscriptstyle 

\scriptsize 

\scriptstyle 

\searrow 

\sec 
base, physics 
\secant 
physics 
\sech 
physics 
\set 
braket 
\Set 
braket 
\setminus 

\sf 

\sharp 

\shortmid 
ams 
\shortparallel 
ams 
\shortvdotswithin 
mathtools 
\shoveleft 
ams, mathtools 
\shoveright 
ams, mathtools 
\sideset 
ams 
\sigma 

\Sigma 

\sim 

\simeq 

\sin 
base, physics 
\sine 
physics 
\singleLine 
bussproofs 
\sinh 
base, physics 
\skew 

\SkipLimits 
ams 
\small 

\smallfrown 
ams 
\smallint 

\smallmatrixquantity 
physics 
\smallsetminus 
ams 
\smallsmile 
ams 
\smash 

\smdet 
physics 
\smile 

\smqty 
physics 
\solidLine 
bussproofs 
\Space 

\space 

\spadesuit 

\sphericalangle 
ams 
\splitdfrac 
mathtools 
\splitfrac 
mathtools 
\spmqty 
physics 
\sPmqty 
physics 
\sqcap 

\sqcup 

\sqrt 

\sqsubset 
ams 
\sqsubseteq 

\sqsupset 
ams 
\sqsupseteq 

\square 
ams 
\stackbin 

\stackrel 

\star 

\strut 

\style 
html 
\subset 

\Subset 
ams 
\subseteq 

\subseteqq 
ams 
\subsetneq 
ams 
\subsetneqq 
ams 
\substack 
ams 
\succ 

\succapprox 
ams 
\succcurlyeq 
ams 
\succeq 

\succnapprox 
ams 
\succneqq 
ams 
\succnsim 
ams 
\succsim 
ams 
\sum 

\sup 

\supset 

\Supset 
ams 
\supseteq 

\supseteqq 
ams 
\supsetneq 
ams 
\supsetneqq 
ams 
\surd 

\svmqty 
physics 
\swarrow 

\symbb 

\symbf 

\symbfcal 

\symbffrak 

\symbfit 

\symbfscr 

\symbfsf 

\symbfsfit 

\symbfsfup 

\symbfup 

\symcal 

\symfrak 

\symit 

\symnormal 

\symrm 

\symscr 

\symsf 

\symsfit 

\symsfup 

\symtt 

\symup 
T¶
\tag 
ams 
\tan 
base, physics 
\tangent 
physics 
\tanh 
base, physics 
\tau 

\tbinom 
ams 
\TeX 

\text 

\textacutedbl 
textcomp 
\textasciiacute 
textcomp 
\textasciibreve 
textcomp 
\textasciicaron 
textcomp 
\textasciicircum 
textcomp 
\textasciidieresis 
textcomp 
\textasciimacron 
textcomp 
\textasciitilde 
textcomp 
\textasteriskcentered 
textcomp 
\textbackslash 
textcomp 
\textbaht 
textcomp 
\textbar 
textcomp 
\textbardbl 
textcomp 
\textbf 

\textbigcircle 
textcomp 
\textblank 
textcomp 
\textborn 
textcomp 
\textbraceleft 
textcomp 
\textbraceright 
textcomp 
\textbrokenbar 
textcomp 
\textbullet 
textcomp 
\textcelsius 
textcomp 
\textcent 
textcomp 
\textcentoldstyle 
textcomp 
\textcircledP 
textcomp 
\textclap 
mathtools 
\textcolonmonetary 
textcomp 
\textcolor 
color 
\textcompwordmark 
textcomp 
\textcopyleft 
textcomp 
\textcopyright 
textcomp 
\textcurrency 
textcomp 
\textdagger 
textcomp 
\textdaggerdbl 
textcomp 
\textdegree 
textcomp 
\textdied 
textcomp 
\textdiscount 
textcomp 
\textdiv 
textcomp 
\textdivorced 
textcomp 
\textdollar 
textcomp 
\textdollaroldstyle 
textcomp 
\textdong 
textcomp 
\textdownarrow 
textcomp 
\texteightoldstyle 
textcomp 
\textellipsis 
textcomp 
\textemdash 
textcomp 
\textendash 
textcomp 
\textestimated 
textcomp 
\texteuro 
textcomp 
\textexclamdown 
textcomp 
\textfiveoldstyle 
textcomp 
\textflorin 
textcomp 
\textfouroldstyle 
textcomp 
\textfractionsolidus 
textcomp 
\textgravedbl 
textcomp 
\textgreater 
textcomp 
\textguarani 
textcomp 
\textinterrobang 
textcomp 
\textinterrobangdown 
textcomp 
\textit 

\textlangle 
textcomp 
\textlbrackdbl 
textcomp 
\textleftarrow 
textcomp 
\textless 
textcomp 
\textlira 
textcomp 
\textllap 
mathtools 
\textlnot 
textcomp 
\textlquill 
textcomp 
\textmarried 
textcomp 
\textmho 
textcomp 
\textminus 
textcomp 
\textmu 
textcomp 
\textmusicalnote 
textcomp 
\textnaira 
textcomp 
\textnineoldstyle 
textcomp 
\textnormal 

\textnumero 
textcomp 
\textohm 
textcomp 
\textonehalf 
textcomp 
\textoneoldstyle 
textcomp 
\textonequarter 
textcomp 
\textonesuperior 
textcomp 
\textopenbullet 
textcomp 
\textordfeminine 
textcomp 
\textordmasculine 
textcomp 
\textparagraph 
textcomp 
\textperiodcentered 
textcomp 
\textpertenthousand 
textcomp 
\textperthousand 
textcomp 
\textpeso 
textcomp 
\textpm 
textcomp 
\textquestiondown 
textcomp 
\textquotedblleft 
textcomp 
\textquotedblright 
textcomp 
\textquoteleft 
textcomp 
\textquoteright 
textcomp 
\textrangle 
textcomp 
\textrbrackdbl 
textcomp 
\textrecipe 
textcomp 
\textreferencemark 
textcomp 
\textregistered 
textcomp 
\textrightarrow 
textcomp 
\textrlap 
mathtools 
\textrm 

\textrquill 
textcomp 
\textsection 
textcomp 
\textservicemark 
textcomp 
\textsevenoldstyle 
textcomp 
\textsf 

\textsixoldstyle 
textcomp 
\textsterling 
textcomp 
\textstyle 

\textsurd 
textcomp 
\textthreeoldstyle 
textcomp 
\textthreequarters 
textcomp 
\textthreesuperior 
textcomp 
\texttildelow 
textcomp 
\texttimes 
textcomp 
\texttip 
action 
\texttrademark 
textcomp 
\texttt 

\texttwooldstyle 
textcomp 
\texttwosuperior 
textcomp 
\textunderscore 
textcomp 
\textup 

\textuparrow 
textcomp 
\textvisiblespace 
textcomp 
\textwon 
textcomp 
\textyen 
textcomp 
\textzerooldstyle 
textcomp 
\tfrac 
ams 
\therefore 
ams 
\theta 

\Theta 

\thickapprox 
ams 
\thicksim 
ams 
\thinspace 

\TIC 
bussproofs 
\tilde 

\times 

\tiny 

\Tiny 

\to 

\toggle 
action 
\top 

\tr 
physics 
\Tr 
physics 
\trace 
physics 
\Trace 
physics 
\triangle 

\triangledown 
ams 
\triangleleft 

\trianglelefteq 
ams 
\triangleq 
ams 
\triangleright 

\trianglerighteq 
ams 
\TrinaryInf 
bussproofs 
\TrinaryInfC 
bussproofs 
\tripledash 
mhchem 
\tt 

\twoheadleftarrow 
ams 
\twoheadrightarrow 
ams 
U¶
\UIC 
bussproofs 
\ulcorner 
ams 
\UnaryInf 
bussproofs 
\UnaryInfC 
bussproofs 
\underbrace 

\underbracket 
mathtools 
\underleftarrow 

\underleftrightarrow 

\underline 

\underparen 

\underrightarrow 

\underset 

\unicode 
unicode 
\unlhd 
ams 
\unrhd 
ams 
\upalpha 
upgreek 
\uparrow 

\Uparrow 

\upbeta 
upgreek 
\upchi 
upgreek 
\updelta 
upgreek 
\Updelta 
upgreek 
\updownarrow 

\Updownarrow 

\upepsilon 
upgreek 
\upeta 
upgreek 
\upgamma 
upgreek 
\Upgamma 
upgreek 
\upharpoonleft 
ams 
\upharpoonright 
ams 
\upiota 
upgreek 
\upkappa 
upgreek 
\uplambda 
upgreek 
\Uplambda 
upgreek 
\uplus 

\upmu 
upgreek 
\upnu 
upgreek 
\upomega 
upgreek 
\Upomega 
upgreek 
\upomicron 
upgreek 
\upphi 
upgreek 
\Upphi 
upgreek 
\uppi 
upgreek 
\Uppi 
upgreek 
\uppsi 
upgreek 
\Uppsi 
upgreek 
\uprho 
upgreek 
\uproot 

\upsigma 
upgreek 
\Upsigma 
upgreek 
\upsilon 

\Upsilon 

\uptau 
upgreek 
\uptheta 
upgreek 
\Uptheta 
upgreek 
\upuparrows 
ams 
\upupsilon 
upgreek 
\Upupsilon 
upgreek 
\upvarepsilon 
upgreek 
\upvarphi 
upgreek 
\upvarpi 
upgreek 
\upvarrho 
upgreek 
\upvarsigma 
upgreek 
\upvartheta 
upgreek 
\upxi 
upgreek 
\Upxi 
upgreek 
\upzeta 
upgreek 
\urcorner 
ams 
\usetagform 
mathtools 
V¶
\va 
physics 
\var 
physics 
\varDelta 
ams 
\varepsilon 

\varGamma 
ams 
\variation 
physics 
\varinjlim 
ams 
\varkappa 
ams 
\varLambda 
ams 
\varliminf 
ams 
\varlimsup 
ams 
\varnothing 
ams 
\varOmega 
ams 
\varphi 

\varPhi 
ams 
\varpi 

\varPi 
ams 
\varprojlim 
ams 
\varpropto 
ams 
\varPsi 
ams 
\varrho 

\varsigma 

\varSigma 
ams 
\varsubsetneq 
ams 
\varsubsetneqq 
ams 
\varsupsetneq 
ams 
\varsupsetneqq 
ams 
\vartheta 

\varTheta 
ams 
\vartriangle 
ams 
\vartriangleleft 
ams 
\vartriangleright 
ams 
\varUpsilon 
ams 
\varXi 
ams 
\vb 
physics 
\vcenter 

\vdash 

\vDash 
ams 
\Vdash 
ams 
\vdot 
physics 
\vdots 

\vdotswithin 
mathtools 
\vec 

\vectorarrow 
physics 
\vectorbold 
physics 
\vectorunit 
physics 
\vee 

\veebar 
ams 
\verb 
verb 
\Vert 

\vert 

\vmqty 
physics 
\vnabla 
physics 
\vphantom 

\vqty 
physics 
\vu 
physics 
\Vvdash 
ams 
W¶
\wedge 

\widehat 

\widetilde 

\wp 

\wr 
X¶
\xcancel 
cancel 
\xhookleftarrow 
mathtools 
\xhookrightarrow 
mathtools 
\xi 

\Xi 

\xleftarrow 
ams 
\xLeftarrow 
mathtools 
\xleftharpoondown 
mathtools 
\xleftharpoonup 
mathtools 
\xleftrightarrow 
mathtools, mhchem 
\xLeftrightarrow 
mathtools 
\xleftrightharpoons 
mathtools 
\xLeftrightharpoons 
mhchem 
\xlongequal 
extpfeil 
\xmapsto 
extpfeil, mathtools 
\xmat 
physics 
\xmathstrut 
mathtools 
\xmatrix 
physics 
\xrightarrow 
ams 
\xRightarrow 
mathtools 
\xrightharpoondown 
mathtools 
\xrightharpoonup 
mathtools 
\xrightleftharpoons 
mathtools, mhchem 
\xRightleftharpoons 
mhchem 
\xtofrom 
extpfeil 
\xtwoheadleftarrow 
extpfeil 
\xtwoheadrightarrow 
extpfeil 
Y¶
\yen 
ams 
Z¶
\zeromatrix 
physics 
\zeta 

\zmat 
physics 
Environments¶
align 
ams 
align* 
ams 
alignat 
ams 
alignat* 
ams 
aligned 
ams 
alignedat 
ams 
array 

bmatrix 
ams 
Bmatrix 
ams 
bmatrix* 
mathtools 
Bmatrix* 
mathtools 
bsmallmatrix 
mathtools 
Bsmallmatrix 
mathtools 
bsmallmatrix* 
mathtools 
Bsmallmatrix* 
mathtools 
cases 
ams 
cases* 
mathtools 
CD 
amscd 
crampedsubarray 
mathtools 
dcases 
mathtools 
dcases* 
mathtools 
drcases 
mathtools 
drcases* 
mathtools 
empheq 
empheq 
eqnarray 

eqnarray* 
ams 
equation 

equation* 
ams 
flalign 
ams 
flalign* 
ams 
gather 
ams 
gather* 
ams 
gathered 
ams 
lgathered 
mathtools 
matrix 
ams 
matrix* 
mathtools 
multline 
ams 
multline* 
ams 
multlined 
mathtools 
numcases 
cases 
pmatrix 
ams 
pmatrix* 
mathtools 
prooftree 
bussproofs 
psmallmatrix 
mathtools 
psmallmatrix* 
mathtools 
rcases 
mathtools 
rcases* 
mathtools 
rgathered 
mathtools 
smallmatrix 
ams, physics 
smallmatrix* 
mathtools 
split 
ams 
spreadlines 
mathtools 
subarray 
ams 
subnumcases 
cases 
vmatrix 
ams 
Vmatrix 
ams 
vmatrix* 
mathtools 
Vmatrix* 
mathtools 
vsmallmatrix 
mathtools 
Vsmallmatrix 
mathtools 
vsmallmatrix* 
mathtools 
Vsmallmatrix* 
mathtools 
xalignat 
ams 
xalignat* 
ams 
xxalignat 
ams 
MathML Support¶
The support for MathML in MathJax involves two functions: the first
looks for <math>
tags within your document and marks them for
later processing by MathJax, and the second converts the MathML to the
internal format used by MathJax, where one of MathJax’s output
processors then displays it in the web page.
In addition, MathJax’s internal format is essentially MathML (with a few additions), implemented as javascript objects rather than DOM elements. MathJax’s various input processors all convert their original format into this internal MathML format, and its output processors take this MathML and produce the proper output from it. Because the internal format is MathMLbased, MathJax provides the ability to convert to and from MathML notation.
Although some browsers have native support for rendering MathML, not all do, and so MathJax makes it possible to view MathML notation in all browsers. Even for those that do support MathML, it may be valuable to use MathJax, since that will produce consistent output across all browsers, and MathJax implements features and functionality that is not available in some native MathML implementations.
MathML in HTML pages¶
For MathML that is handled via the preprocessor, you should not use
named MathML entities, but rather use numeric entities like
√
or unicode characters embedded in the page itself. The
reason is that entities are replaced by the browser before MathJax
runs, and some browsers report errors for unknown entities. For
browsers that are not MathMLaware, that will cause errors to be
displayed for the MathML entities. While that might not occur in the
browser you are using to compose your pages, it can happen with other
browsers, so you should avoid the named entities whenever possible.
If you must use named entities, you may need to declare them in the
DOCTYPE declaration by hand.
When you use MathML in an HTML document rather than an XHTML one (MathJax will work with both), you should not use the “selfclosing” form for MathML tags with no content, but should use separate open and close tags. That is, use
<mspace width="thinmathspace"></mspace>
rather than <mspace width="thinmathspace" />
. This is because
HTML does not have selfclosing tags, and some browsers will get the
nesting of tags wrong if you attempt to use them. For example, with
<mspace width="1em" />
, since there is no closing tag, the rest of
the mathematics will become the content of the <mspace>
tag; but
since <mspace>
should have no content, the rest of the mathematics
will not be displayed. This is a common error that should be avoided.
Modern browsers that support HTML5 should be able to handle
selfclosing tags, but older browsers have problems with them, so if
you want your mathematics to be visible to the widest audience, do not
use the selfclosing form in HTML documents.
Supported MathML tags¶
MathJax supports the MathML3.0 mathematics tags, with some limitations. The MathML support is still under active development, so some tags are not yet implemented, and some features are not fully developed, but are coming.
The deficiencies include:
 No support for alignment groups in tables.
 Not all attributes are supported for tables. E.g.,
columnspan
androwspan
are not implemented yet.  Experimental support for the elementary math tags:
mstack
,mlongdiv
,msgroup
,msrow
,mscarries
, andmscarry
(via themml3
extension, see below).  Experimental support for bidirectional mathematics (via the
mml3
extension, see below).
See the results of the MathML3.0 test suite for details.
Content MathML¶
The version 2 contentmathml
extension is not yet available in
version 3.
Experimental mml3 extension¶
MathML includes a number of tags that support elementaryschool
mathematics, like <mstack>
and <mlongdiv>
. MathJax has only
experimental support for these tags via the mml3 extension. This
uses an XSLT transform to convert these tags into other presentation
MathML tags that MathJax has implemented. This does a reasonable job
for some constructs, and a poorer job for others, but it does make it
possible to process elementary math within MathJax. Better support is
planned for the future.
To activate experimental features in your documents, simply include
[mml]/mml3
in the load
array of the loader
section of your
configuration:
MathJax = {
loader: {load: ['[mml]/mml3']}
};
This will install a prefilter on the MathML input jax that performs the XSLT transform before processing it.
Semantics and Annotations¶
Some popular annotation formats like TeX, Maple, or Content MathML are
often included in the MathML source via the semantics
element.
This is particularly true of MathML that is generated by other
software, such as editors or computational tools.
MathJax provides access to these annotations through the "Show Math
As"
menu, via the Annotations
submenu. See the MathML Annotation Framework and
the Contextual Menu Options documentation for details.
AsciiMath Support¶
The support for AsciiMath in MathJax involves two functions: the first
looks for mathematics within your web page (indicated by delimiters
like `...`
) and marks the mathematics for later processing by
MathJax, and the second is what converts the AsciiMath notation into
MathJax’s internal format, where one of MathJax’s output processors
then displays it in the web page. In MathJax version 2, these were
separated into distinct components (the asciimath2jax
preprocessor
and the AsciiMath input jax), but in version 3, the asciimath2jax
functions have been folded into the AsciiMath input jax.
The AsciiMath input jax actually includes a copy of ASCIIMathML.js
itself (see the AsciiMath home page for
details). This means that the results of MathJax’s AsciiMath
processing should be the same as using the actual ASCIIMathML.js
package (at least as far as the MathML that it generates is
concerned). Thanks go to David Lippman for writing the initial
version of the AsciiMath preprocessor and input jax and for the
ongoing improvements from the AsciiMath community.
The AsciiMath input jax handles only the original ASCIIMathML notation (from ASCIIMathML v1.4.7), not the extended LaTeXMathML notation added in version 2.0 of ASCIIMathML, though the AsciiMath input jax does expose the tables that define the symbols that AsciiMath processes, and so it would be possible to extend them to include additional symbols. In general, it is probably better to use MathJax’s TeX input jax to handle LaTeX notation.
AsciiMath can be configured to look for whatever markers you want to use for your math delimiters. See the AsciiMath configuration options section for details on how to customize the action of the AsciiMath input jax.
Loading the AsciiMath Component¶
The AsciiMath input jax has not yet been fully ported to version 3. Instead, the AsciiMath component uses the version 2 AsciiMath input jax together with some of the legacy version 2 code patched into the version 3 framework. This is less efficient, and somewhat larger, than a pure version3 solution would be, and it can complicate the configuration process. A full version3 port of AsciiMath is planned for a future release.
Because AsciiMath hasn’t been fully ported to version 3, none of the
combined components include it. So in order to use AsciiMath
notation, you will need to configure MathJax to load it yourself by
adding input/asciimath
to the load
array in the loader
block of your MathJax configuration. For example,
<script>
MathJax = {
loader: {load: ['input/asciimath', 'output/chtml', 'ui/menu']},
};
</script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js">
</script>
would load the AsciiMath input jax, the CommonHTML output jax, and the contextual menu component.
AsciiMath delimiters¶
By default, the AsciiMath processor defines the backtick
(`
) as the delimiters for mathematics in AsciiMath format. It
does not define $...$
as math delimiters. That is because
dollar signs appear too often in nonmathematical settings, which
could cause some text to be treated as mathematics unexpectedly. For
example, with singledollar delimiters, “… the cost is $2.50 for the
first one, and $2.00 for each additional one …” would cause the
phrase “2.50 for the first one, and” to be treated as mathematics
since it falls between dollar signs. For this reason, if you want to
use singledollars for AsciiMath notation, you must enable that
explicitly in your configuration:
window.MathJax = {
loader: {
load: ['input/asciimath']
},
asciimath: {
delimiters: [['$','$'], ['`','`']]
}
});
Note that the dollar signs are frequently used as a delimiter for mathematics in the TeX format, and you can not enable the dollarsign delimiter for both. It is probably best to leave dollar signs for TeX notation.
See the AsciiMath Input Processor Options page, for additional configuration parameters that you can specify for the AsciiMath input processor.
AsciiMath in HTML documents¶
The AsciiMath syntax is described on the official AsciiMath homepage.
Keep in mind that your mathematics is part of an HTML document, so you
need to be aware of the special characters used by HTML as part of its
markup. There cannot be HTML tags within the math delimiters (other
than <br>
, <wbr>
, and HTML comments) as AsciiMathformatted
math does not include HTML tags. Also, since the mathematics is
initially given as text in the page, you need to be careful that your
mathematics doesn’t look like HTML tags to the browser, which parses
the page before MathJax gets to see it. In particular, that means
that you have to be careful about things like lessthan and
greaterthan signs (<
and >
), and ampersands (&
), which
have special meaning to web browsers. For example,
... when `x<y` we have ...
will cause a problem, because the browser will think <y
is the
beginning of a tag named y
(even though there is no such tag in
HTML). When this happens, the browser will think the tag continues up
to the next >
in the document (typically the end of the next
actual tag in the HTML file), and you may notice that you are missing
part of the text of the document. In the example above, the “<y
”
and “we have ...
” will not be displayed because the browser thinks
it is part of the tag starting at <y
. This is one indication you
can use to spot this problem; it is a common error and should be
avoided.
Usually, it is sufficient simply to put spaces around these symbols to cause the browser to avoid them, so
... when `x < y` we have ...
should work. Alternatively, you can use the HTML entities <
,
>
and &
to encode these characters so that the browser
will not interpret them, but MathJax will. E.g.,
... when `x < y` we have ...
Keep in mind that the browser interprets your text before MathJax does.
MathJax Output Formats¶
Currently, MathJax can render math in three ways:
 Using HTML and CSS to lay out the mathematics,
 Using Scalable Vector Graphics (SVG) to lay out the mathematics, or
 As a serialized MathML string.
The first two are implemented by the CommonHTML
and SVG
output
processors. The third is a consequence of the fact that MathJax uses
MathML as its internal format. While MathJax version 2 included a
NativeMML
output processor that produced MathML notation for those
browsers that support it, this has been dropped from version 3. See
the MathML Support section for more information on how to get
MathML output.
If you are using one of the combined component files, then this will
select one of these output processors for you. If the component file
ends in chtml
, then it is the CommonHTML output processor, while
if it ends in svg
then the SVG output processor will be used.
If you are performing your own inline or filebased configuration,
you select which one you want to use by including either
'output/chtml'
or 'output/svg'
in the load
array of the
loader
section of your MathJax configuration. For example
window.MathJax = {
loader: {load: ["input/tex", "output/chtml"]}
};
would specify TeX input and CommonHTML output for the mathematics in your document.
Warning
The PreviewHTML
, PlainSource
, and NativeMML
output
formats from version 2 are not available in version 3. These may
be available in future releases if there is demand for them.
HTML Support¶
The CommonHTML output processor renders your mathematics using HTML
with CSS styling. It produces highquality output in all modern
browsers, with results that are consistent across browsers and
operating systems. This is MathJax’s primary output mode since
MathJax version 2.6. Its major advantage is its quality, consistency,
and the fact that its output is independent of the browser, operating
system, and user environment. This means you can preprocess
mathematics on a server, without needing to know the browser, what
fonts are available, and so on. (In version 2, both the HTMLCSS
and NativeMML
processors produced different output for different
browsers and user environments.)
The CommonHTML output uses webbased fonts so that users don’t have to have math fonts installed on their computers, but will use locally installed ones if they are available. It currently only supports MathJax’s default TeX fonts (see the MathJax Font Support section for more information).
See CommonHTML Output Processor Options for information about the options that control the CommonHTML output.
SVG Support¶
The SVG
output processor uses Scalable Vector Graphics to render
the mathematics on the page. SVG is supported in all the major
browsers and most mobile devices; note, however, that Internet
Explorer prior to IE9 does not support SVG (MathJax version 3 doesn’t
support these in any case), and IE9 only does in “IE9 standards mode”,
not its emulation modes for earlier versions. The SVG output mode is
high quality, and displays and prints well in all browsers. Since it
uses SVG data instead of font files, it is not affected by userbased
webfont blocking, or other character placement issues that sometimes
occur with the HTMLbased output.
One advantage to the SVG output is that it is relatively selfcontained (it does not rely heavily on CSS, though it does use some in certain circumstances), so it can be saved and used as an independent image. One disadvantage of this mode is that its variablewidth tables become fixed size once they are typeset, and don’t rescale if the window size changes (for example).
In version 2, equation tags and numbers where produced using a fixed width as well, so the equation number would not change with changes in window size. In version 3, however, equation numbers now are based on the container size, and move with changes in its size, just as they do with CommonHTML output.
Finally, because mathematical characters in SVG output are produced by SVG paths, not characters in a font, they can’t be copy and pasted, as the output of the CommonHTML processor can.
See SVG Output Processor Options for information about the options that control the SVG output.
MathML Support¶
MathJax uses MathML as the basis for its internal format for
mathematical expressions, so MathML support is built into MathJax at a
fundamental level. There is a MathML input jax
for converting from MathML elements into the internal format
(javascript objects representing the MathML elements), and there is a
mechanism that can convert the internal format into a serialized
MathML string provided by MathJax.startup.toMML()
(if you are
using MathJax components).
While MathJax version 2 included a NativeMML output jax for producing MathML output in the web page, because MathML is not available in the Chrome, Edge, and IE browsers, because the MathML support in Safari and Firefox don’t include all the features needed by MathJax (e.g., the <mlabeledtr> element needed for labeled equations), and because the quality of the results in Safari and Firefox are not always comparable to the output from MathJax, the NativeMML output jax is no longer provided in MathJax version 3.
You can, however, use MathJax’s MathML serialization features to implement your own native MathML output if you wish. Here is one example that does so for TeX input to MathML output.
<style>
mjxcontainer[display="block"] {
display: block;
margin: 1em 0;
}
</style>
<script>
MathJax = {
//
// Load only TeX input and the contextual menu
//
loader: {load: ['input/tex', 'ui/menu']},
//
// When page is ready, render the math in the document
//
//
// When page is ready:
// disable the assistivemathml menu item
// render the document, handling require and autoload calls
//
startup: {
pageReady() {
MathJax.startup.document.menu.menu.findID('Accessibility', 'AssistiveMml').disable();
MathJax._.mathjax.mathjax.handleRetriesFor(() => MathJax.startup.document.render());
}
},
//
// Override the usual typeset render action with one that generates MathML output
//
options: {
renderActions: {
assistiveMml: [], // disable assistive mathml
typeset: [150,
(doc) => {for (math of doc.math) {MathJax.config.renderMathML(math, doc)}},
(math, doc) => MathJax.config.renderMathML(math, doc)
]
},
menuOptions: {
settings: {
assistiveMml: false
}
}
},
//
// The action to use for rendering MathML
//
renderMathML(math, doc) {
math.typesetRoot = document.createElement('mjxcontainer');
math.typesetRoot.innerHTML = MathJax.startup.toMML(math.root);
math.display && math.typesetRoot.setAttribute('display', 'block');
}
};
</script>
<script type="text/javascript" id="MathJaxscript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js">
</script>
This example uses the startup component to load just
the input/tex and contextual menu components, and defines a new render action that
replaces the standard typeset
action with one that creates a
MathJax container element and stores it in math.typesetRoot
,
then converts the internal format to a MathML string (via
MathJax.startup.toMML()
) and has the browser parse that into
DOM element (via innerHTML
). A later render action will move
the container and its MathML contents into the DOM at the proper
location. For math that is in display style, the container is marked
with an attribute so that CSS can be used to make the container be a
blocklevel element with some top and bottom margin.
The example also takes several steps to disable the Assistive MathML
extension that inserts hidden MathML for the usual output renders.
This is unneeded since we are generating MathML ourselves as the
primary output. Setting the menuOptions.settings.assistiveMml
option to false
turns off the assistive MathML in the contextual
menu. The pageReady()
function also includes a line that
disables the assistiveMathML item in the menu, so user’s can’t
accidentaly turn it on again. Finally, the assistiveMml render
action is disabled, since it will never be activated (overkill
perhaps, but no need to run the usual code for nothing).
Note
MathJax’s version 2 NativeMML output processor worked around various limitations of Firefox/Gecko and Safari/WebKit (e.g., to provide support for equation labels), but this approach does not, as it just uses the generic MathML.
Lazy Typesetting¶
MathJax offers an extension that is designed to improve the performance of pages with large numbers of equations. It implements a “lazy typesetting” approach that only processes an expression when it comes into view. This means that expressions will not be typeset when they are not visible, and your readers will not have to wait for the entire document to typeset, speeding up their initial view of the page. Furthermore, any expressions that are never seen will not be typeset, saving the processing time that would normally have been spent on those expressions.
This also helps with the situation where you may link to a particular location in your page (via a URL with a hash); typesetting the material above that point can cause the browser to change the scroll position, and so the user may not end up at the proper location in the page. With the lazy extension, the material above that point is not typeset until the user scrolls upwards, and so there is no position change.
To use the lazy typesetting extension, simply add it to your configuration as follows:
MathJax = {
loader: {load: ['ui/lazy']}
};
This will adjust the typesetting pipeline to implement the lazytypesetting functionality.
Lazy typesetting works best with SVG output, but changes with the way
the CommonHTML output handles its stylesheet updates make the CHTML
output nearly as fast. With TeX input, the lazy extension makes sure
that previous expressions are processed by TeX (though not output to
the page) so that any macro definitions or automatic equation numbers
are in place when the visible expressions are processed. Currently,
documents that contain \ref
or \eqref
links may not yet work
properly, since target equations may not have been typeset, and so the
link location may not be marked in the document. In particular,
forward references are unlikely to work, and backward references will
work only if the target expression has already been typeset. We hope
to improve this situation in a future release.
Lazy Typesetting Options¶
Adding the ui/lazy extension to the loader.load array adds the following options to the MathJax configuration:
MathJax = {
options: {
lazyMargin: '200px',
lazyAlwaysTypeset: null
}
};

lazyMargin: '200px'
This gives the extent of the typesetting margin outside the visible viewport. When mathematics appears within this range of the viewport, it will be typeset. This allows typesetting to occur slightly before the math appears in the window, for a smoother effect.

lazyAlwaysTypeset: null
This gives an array of containers whose math expressions should always be typset during the initial typesetting pass, rather than waiting for them to scroll into view. This may be useful if MathJax output appears in diagrams or other layout that must be sized and placed during initial page layout.
Automatic Line Breaking¶
Automatic line breaking has not yet been implemented in MathJax version 3, but is high on our list for inclusion in a future release.
MathJax Font Support¶
MathJax version 3 currently supports only one font, the MathJax TeX font. Version 2 provides the following fonts:
 MathJax TeX (default)
 STIX General
 Asana Math
 Neo Euler
 Gyre Pagella
 Gyre Termes
 Latin Modern
MathJax contains customized webfont versions of these fonts. In particular, these customized versions are split over several files to minimize the page load.
MathJax 3 will support these fonts in a future version.
Use of Other Fonts¶
In version 2 of MathJax, it was difficult to adjust the fonts in use (once loaded), or to replace individual or collections of characters being used. For example, switching the variables and function names to use a sansserif font rather than the standard serifed font is quite difficult in version 2. The structure of the font data in version 3 has been completely redesigned to help make such changes easier to make.
Since browsers do not provide APIs to access font metrics, MathJax has to ship with the necessary font data; this font data is generated during development and cannot be determined easily on the fly. The tools for creating the data needed by MathJax have not yet been created for version 3 (the data for the MathJax TeX font was converted from the version 2 format by hand). These tools are high on the list for inclusion in the next version of MathJax, which should provide the additional fonts missing from the initial release of version 3. At that point, the details of how to mixandmatch font characters, and how to create the data files for your own fonts for use in MathJax, will be provided.
Character fallbacks¶
No font contains a suitable glyph for every character specified in the Unicode standard. When MathJax encounters a character that isn’t in the font that it is using, it will fall back to other fonts in a variety of ways.
First, MathJax enhances Unicode coverage of its default TeX fonts,
e.g., combining two double integrals U+222C
when a quadruple
integral U+2A0C
is used. However, this cannot create every
character specified in Unicode. Next, MathJax will run through a
fallback chain within the configured fonts (e.g., upright Greek will
be substituted with italic Greek).
Finally, when all else fails, MathJax will ask the browser to provide the glyph from a system font. Since in that final case, MathJax will not have the necessary data on the glyph’s bounding box, MathJax will guess these metrics. When run in a browser, MathJax will be able to determine the character’s width, but not its height and depth, so it will use default values these metrics. Measuring the width can negatively affect the rendering speed, and guessing the height and depth can reduce the quality of the resulting output. When used on a server or in a commandline application, MathJax won’t even be able to determine the width, and that has an even more serous consequences for the layout, in general. Thus it is best to use only the characters that are in the MathJax fonts when using serverside rendering.
Browser Compatibility¶
Extensive browser support is an important goal for MathJax; at the same time, MathJax does require a certain minimum level of browser functionality. While MathJax version 2 went to great lengths to remain compatible with early versions of most browsers (even back to IE6), MathJax version 3 relies on more modern browser features, and so older browsers are no longer supported.
The CommonHTML and SVG output supports all modern browsers (Chrome, Safari, Firefox, Edge), and most mobile browsers. Include the polyfill library in order to support earlier browser versions (see their browser support page for details). In particular, to allow MathJax version 3 to work with IE11, include the line
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
before the script that loads MathJax.
Please file issues on GitHub if you notice inaccuracies or problems. It may help to add a screenshot; we suggest services such as browsershots.org, saucelabs.com, or browserstack.com for obtaining them.
Viewport meta tag¶
The viewport meta tag provides the browser with instructions regarding viewports and zooming. This way, web developers can control how a webpage is displayed on a mobile device.
Incorrect or missing viewport information can confuse MathJax’s layout process, leading to very small font sizes. We recommend that you use standard values such as the following:
<meta name="viewport" content="width=devicewidth, initialscale=1">
Internet Explorer Emulation modes¶
Internet Explorer provides socalled emulation modes for backward compatibility to its legacy versions. These emulation modes have been deprecated since Internet Explorer 11, cf. Microsoft documentation.
MathJax is fastest when in the standards mode of each IE version, so it is best to force the highest mode possible. That can be accomplished by adding
<meta httpequiv="XUACompatible" content="IE=edge">
at the top of the <head>
section of your HTML documents.
Note
This line must come at the beginning of the <head>
, before
any stylesheets, scripts, or other content are loaded.
Note that versions of IE prior to 11 are no longer supported in MathJax version 3.
Configuring MathJax¶
The various components of MathJax, including its input and output
processors, its extensions, and the MathJax core,
all can be configured though a MathJax
global object that
specifies the configuration you want to use. The MathJax
object consists of subobjects that configure the individual
components of MathJax. For example, the input/tex
component is configured through a tex
block within the
MathJax
object, while the startup component
is configured through the startup
block.
These blocks are JavaScript objects that includes name: value
pairs giving the names of parameters and their values, with pairs
separated by commas. Be careful not to include a comma after the last
value, however, as some browsers will fail to process the
configuration if you do.
Some blocks may contain further subblocks. For example, the tex
block can have a macros
subblock that predefines macros, and a
tagformat
block (when the tagformat component is used)
to define how equation tags are displayed and handled.
For example,
window.MathJax = {
loader: {
load: ['[tex]/tagformat']
},
startup: {
pageReady: () => {
alert('Running MathJax');
return MathJax.startup.defaultPageReady();
}
},
tex: {
packages: {'[+]': ['tagformat']},
tagSide: 'left',
macros: {
RR: '{\\bf R}',
bold: ['{\\bf #1}',1]
},
tagformat: {
tag: (n) => '[' + n + ']'
}
}
};
is a configuration that asks for the tagformat extension to
be loaded, sets up the startup component to have a
function that it runs when the page (and MathJax) are ready (the
function issues an alert and then does the usual pageReady()
function, which typesets the page), configures the TeX input component to use the tagformat extension, asks for
displayed equations to be typeset to the left (rather than centered),
defines two macros, and finally set the tagging so that it uses square
brackets rather than parentheses for equation numbers and tags.
Note the special notation used with the packages
option above.
The packages
property is an array of extension names, but the
configuration uses a special object to add to that array rather than
replace it. If the option you are setting is an array, and you
provide an object that has a single properly whose name is '[+]'
and whose value is an array, then that array will be appended to the
default value for the option you are setting. So in the example
above, the 'tagformat'
string is added to the default packages
array (without your needing to know what that default value is).
Similarly, if you use an object with a single property whose name is
'[]'
and whose value is an array, the elements in that array are
removed from the default value of the option you are setting. For
example,
packages: {'[]': ['autoload', 'require']}
would remove the autoload and require packages from the default
packages
array.
Finally, you can combine '[+]'
and '[]'
in one object to do
both actions. E.g.,
packages: {'[+]': ['enclose'], '[]': ['autoload', 'require']}
would remove the autoload and require packages from the default
packages
array, and add enclose to the result.
In the links below, the various options are first listed with their default values as a complete configuration block, and then each option is explained further below that.
Input Processor Options¶
TeX Input Processor Options¶
The options below control the operation of the TeX input
processor that is run when you include 'input/tex'
,
'input/texfull'
, or 'input/texbase'
in the load
array of
the loader
block of your MathJax configuration, or if you load a
combined component that includes the TeX input jax. They are listed
with their default values. To set any of these options, include a
tex
section in your MathJax
global object.
The Configuration Block¶
MathJax = {
tex: {
packages: ['base'], // extensions to use
inlineMath: [ // start/end delimiter pairs for inline math
['\\(', '\\)']
],
displayMath: [ // start/end delimiter pairs for display math
['$$', '$$'],
['\\[', '\\]']
],
processEscapes: true, // use \$ to produce a literal dollar sign
processEnvironments: true, // process \begin{xxx}...\end{xxx} outside math mode
processRefs: true, // process \ref{...} outside of math mode
digits: /^(?:[09]+(?:\{,\}[09]{3})*(?:\.[09]*)?\.[09]+)/,
// pattern for recognizing numbers
tags: 'none', // or 'ams' or 'all'
tagSide: 'right', // side for \tag macros
tagIndent: '0.8em', // amount to indent tags
useLabelIds: true, // use label name rather than tag for ids
maxMacros: 1000, // maximum number of macro substitutions per expression
maxBuffer: 5 * 1024, // maximum size for the internal TeX string (5K)
baseURL: // URL for use with links to tags (when there is a <base> tag in effect)
(document.getElementsByTagName('base').length === 0) ?
'' : String(document.location).replace(/#.*$/, '')),
formatError: // function called when TeX syntax errors occur
(jax, err) => jax.formatError(err)
}
};
Note that some extensions make additional options available. See the TeX Extension Options section below for details.
Note
The default for processEscapes
has changed from
false
in version 2 to true
in version 3.
Note
Prior to version 3.2, the multlineWidth
option used to be in the
main tex
block, but it is now in the ams
subblock of the
tex
block. Version 3.2 includes code to move the configuration
from its old location to its new one, but that
backwardcompatibility code will be removed in a future vesion.
Option Descriptions¶

packages: ['base']
This array lists the names of the packages that should be initialized by the TeX input processor. The input/tex and input/texfull components automatically add to this list the packages that they load. If you explicitly load addition tex extensions, you should add them to this list. For example:
MathJax = { loader: {load: ['[tex]/enclose']}, tex: { packages: {'[+]': ['enclose']} } };
This loads the enclose extension and acticates it by including it in the package list.
You can remove packages from the default list using
'[]'
rather than[+]
, as in the followiong example:MathJax = { tex: { packages: {'[]': ['noundefined']} } };
This would disable the noundefined extension, so that unknown macro names would cause error messages rather than be displayed in red.
If you need to both remove some default packages and add new ones, you can do so by including both within the braces:
MathJax = { loader: {load: ['[tex]/enclose']}, tex: { packages: {'[]': ['noundefined', 'autoload'], '[+]': ['enclose']} } };
This disables the noundefined and autoload extensions, and adds in the enclose extension.

inlineMath: [['\(','\)']]
This is an array of pairs of strings that are to be used as inline math delimiters. The first in each pair is the initial delimiter and the second is the terminal delimiter. You can have as many pairs as you want. For example,
inlineMath: [ ['$','$'], ['\\(','\\)'] ]
would cause MathJax to look for
$...$
and\(...\)
as delimiters for inline mathematics. (Note that the single dollar signs are not enabled by default because they are used too frequently in normal text, so if you want to use them for math delimiters, you must specify them explicitly.)Note that the delimiters can’t look like HTML tags (i.e., can’t include the lessthan sign), as these would be turned into tags by the browser before MathJax has the chance to run. You can only include text, not tags, as your math delimiters.

displayMath: [ ['$$','$$'], ['\[','\]'] ]
This is an array of pairs of strings that are to be used as delimiters for displayed equations. The first in each pair is the initial delimiter and the second is the terminal delimiter. You can have as many pairs as you want.
Note that the delimiters can’t look like HTML tags (i.e., can’t include the lessthan sign), as these would be turned into tags by the browser before MathJax has the chance to run. You can only include text, not tags, as your math delimiters.

processEscapes: false
When set to
true
, you may use\$
to represent a literal dollar sign, rather than using it as a math delimiter, and\\
to represent a literal backslash (so that you can use\\\$
to get a literal\$
or\\$...$
to get a backslash jsut before inline math). Whenfalse
,\$
will not be altered, and its dollar sign may be considered part of a math delimiter. Typically this is set totrue
if you enable the$ ... $
inline delimiters, so you can type\$
and MathJax will convert it to a regular dollar sign in the rendered document.

processRefs: true
When set to
true
, MathJax will process\ref{...}
outside of math mode.

processEnvironments: true
When
true
, tex2jax looks not only for the inline and display math delimiters, but also for LaTeX environments (\begin{something}...\end{something}
) and marks them for processing by MathJax. Whenfalse
, LaTeX environments will not be processed outside of math mode.

digits: /^(?:[09]+(?:{,}[09]{3})*(?:.[09]*)?.[09]+)/
This gives a regular expression that is used to identify numbers during the parsing of your TeX expressions. By default, the decimal point is
.
and you can use{,}
between every three digits before that. If you want to use{,}
as the decimal indicator, useMathJax = { tex: { digits: /^(?:[09]+(?:\{,\}[09]*)?\{,\}[09]+)/ } };

tags: 'none'
This controls whether equations are numbered and how. By default it is set to
'none'
to be compatible with earlier versions of MathJax where autonumbering was not performed (so pages will not change their appearance). You can change this to'ams'
for equations numbered as the AMSmath package would do, or'all'
to get an equation number for every displayed equation.

tagSide: 'right'
This specifies the side on which
\tag{}
macros will place the tags, and on which automatic equation numbers will appear. Set it to'left'
to place the tags on the lefthand side.

tagIndent: "0.8em"
This is the amount of indentation (from the right or left) for the tags produced by the
\tag{}
macro or by automatic equation numbers.

useLabelIds: true
This controls whether element IDs for tags use the
\label
name or the equation number. Whentrue
, use the label, whenfalse
, use the equation number.

maxMacros: 10000
Because a definition of the form
\def\x{\x} \x
would cause MathJax to loop infinitely, themaxMacros
constant will limit the number of macro substitutions allowed in any expression processed by MathJax.

maxBuffer: 5 * 1024
Because a definition of the form
\def\x{\x aaa} \x
would loop infinitely, and at the same time stack up lots of a’s in MathJax’s equation buffer, themaxBuffer
constant is used to limit the size of the string being processed by MathJax. It is set to 5KB, which should be sufficient for any reasonable equation.

baseURL: (document.getElementsByTagName('base').length === 0) ?

'' : String(document.location).replace(/#.*$/, ''))
This is the base URL to use when creating links to tagged equations (via
\ref{}
or\eqref{}
) when there is a<base>
element in the document that would affect those links. You can set this value by hand if MathJax doesn’t produce the correct link.

formatError: (jax, err) => jax.formatError(err)
This is a function that is called when the TeX input jax reports a syntax or other error in the TeX that it is processing. The default is to generate an
<merror>
MathML element with the message indicating the error that occurred. You can override the function to perform other tasks, like recording the message, replacing the message with an alternative message, or throwing the error so that MathJax will stop at that point (you can catch the error using promises or atry/carch
block).
The remaining options are described in the Options Common to All Input Processors section.
Developer Options¶
In addition to the options listed above, lowlevel options intended for developers include the following:

FindTeX: null
The
FindTeX
object instance that will override the default one. This allows you to create a subclass ofFindTeX
and pass that to the TeX input jax. Anull
value means use the defaultFindTeX
class and make a new instance of that.
TeX Extension Options¶
Several of the TeX extensions make additional options available in the
tex
block of your MathJax configuration. These are described
below. Note that the input/tex component, and the
combined components that load the TeX input jax, include a number of
these extensions automatically, so some these options will be
available by default.
For example, the configmacros package adds a macros
block to the tex
configuration block that allows you to predefine
macros for use in TeX espressions:
MathJax = {
tex: {
macros: {
R: '\\mathbf{R}'
}
}
}
The options for the various TeX packages (that have options) are described in the links below:
Setting Options from within TeX Expressions¶
It is sometimes convenient to be able to change the value of a TeX or
TeX extension option from within a TeX expression. For example, you
might want to change the tag side for an individual expression. The
setoptions extension allows you to do just that. It
defines a \setOptions
macro that allows you to change the values
of options for the TeX parser, or the options for a given TeX package.
Because this functionality can have potential adverse consequences on a page that allows community members to enter TeX notation, this extension is not loaded by default, and can’t be loaded by require{}. You must load it and add it to the tex package list explicitly in order to allow the options to be set. The extension has configuration parameters that allow you to control which packages and options can be modified from within a TeX expression, and you may wish to adjust those if you are using this macro in a community setting.
MathML Input Processor Options¶
The options below control the operation of the MathML input
processor that is run when you include
'input/mml'
in the load
array of the loader
block of
your MathJax configuration, or if you load a combined component that
includes the MathML input jax. They are listed with their default
values. To set any of these options, include an mml
section in
your MathJax
global object.
The Configuration Block¶
MathJax = {
mml: {
parseAs: 'html', // or 'xml'
forceReparse: false, // true to serialize and reparse all MathML
parseError: function (node) { // function to process parsing errors
this.error(this.adaptor.textContent(node).replace(/\n.*/g, ''));
},
verify: { // parameters controling verification of MathML
checkArity: true, // check if number of children is correct
checkAttributes: false, // check if attribute names are valid
fullErrors: false, // display full error messages or just error node
fixMmultiscripts: true, // fix unbalanced mmultiscripts
fixMtables: true // fix incorrect nesting in mtables
}
}
};
Option Descriptions¶

parseAs: 'html'
Specifies how MathML strings should be parsed: as XML or as HTML. When set to
'xml'
, the browser’s XML parser is used, which is more strict about format (e.g., matching end tags) than the HTML parser, which is the default. In node application (where theliteDOM
is used), these both use the same parser, which is not very strict.

forceReparse: false
Specifies whether MathJax will serialize and reparse MathML found in the document. This can be useful if you want to do XML parsing of the MathML from an HTML document.

parseError: (node) => {...}
Specifies a function to be called when there is a parsing error in the MathML (usually only happens with XML parsing). The
node
is a DOM node containing the error text. Your function can process that in any way it sees fit. The default is to call the MathML input processor’s error function with the text of the error (which will create anmerror
node with the error message). Note that this function runs withthis
being the MathML input processor object.

verify: {...}
This object controls what verification/modifications are to be performed on the MathML that is being processed by MathJax. The values that can be included in the
verify
object are the following:
checkArity: true
This specifies whether the number of children is verified or not. The default is to check for the correct number of children. If the number is wrong, the node is replaced by an
<merror>
node containing either a message indicating the wrong number of children, or the name of the node itself, depending on the setting offullErrors
below.

checkAttributes: false
This specifies whether the names of all attributes are checked to see if they are valid on the given node (i.e., they have a default value, or are one of the standard attributes such as
style
,class
,id
,href
, or adata
attribute. If an attribute is in error, the node is either placed inside an<merror>
node (so that it is marked in the output as containing an error), or is replaced by an<merror>
containing a full message indicating the bad attribute, depending on the setting offullErrors
below.Currently only names are checked, not values. Value verification may be added in a future release.

fullErrors: false
This specifies whether a full error message is displayed when a node produces an error, or whether just the node name is displayed (or the node itself in the case of attribute errors).

fixMmultiscripts: true
This specifies whether extra
<none/>
entries are added to<mmultiscripts>
elements to balance the super ans subscripts, as required by the specification, or whether to generate an error instead.

fixMtables: true
This specifies whether missing
<mtable>
,<mtr>
and<mtd>
elements are placed around cells or not. Whentrue
, MathJax will attempt to correct the table structure if these elements are missing from the tree. For example, an<mtr>
element that is not within an<mtable>
will have an<mtable>
placed around it automatically, and an<mtable>
containing an<mi>
as a direct child node will have an<mtr>
and<mtd>
inserted around the<mi>
.

Developer Options¶
In addition to the options listed above, lowlevel options intended for developers include the following:

FindMathML: null
The
FindMathML
object instance that will override the default one. This allows you to create a subclass ofFindMathML
and pass that to the MathML input jax. Anull
value means use the defaultFindMathML
class and make a new instance of that.

MathMLCompile: null
The
MathMLCompile
object instance that will override the default one. This allows you to create a subclass ofMathMLCompile
and pass that to the MathML input jax. Anull
value means use the defaultMathMLCompile
class and make a new instance of that.
AsciiMath Input Processor Options¶
The options below control the operation of the AsciiMath input
processor that is run when you include
'input/asciimath'
in the in the load
array of the loader
block of your MathJax configuration, or if you load a combined
component that includes the AsciiMath input jax (none currently do,
since the AsciiMath input has not been fully ported to version 3).
They are listed with their default values. To set any of these
options, include an asciimath
section in your MathJax
global
object.
The Configuration Block¶
MathJax = {
asciimath: {
fixphi: true, // true for TeX mapping, false for unicode mapping
displaystyle: true, // true for displaystyle typesetting, false for inline
decimalsign: '.' // character to use for decimal separator
}
};
Option Descriptions¶

fixphi: true
Determines whether MathJax will switch the Unicode values for
phi
andvarphi
. If set totrue
MathJax will use the TeX mapping, otherwise the Unicode mapping.

displaystyle: true
Determines whether operators like summation symbols will have their limits above and below the operators (true) or to their right (false). The former is how they would appear in displayed equations that are shown on their own lines, while the latter is better suited to inline equations so that they don’t interfere with the line spacing so much.

decimalsign: "."
This is the character to be used for decimal points in numbers. If you change this to
','
, then you need to be careful about entering points or intervals. E.g., use(1, 2)
rather than(1,2)
in that case.
The remaining options are described in the Options Common to All Input Processors section.
Developer Options¶
In addition to the options listed above, lowlevel options intended for developers include the following:

FindAsciiMath: null
The
FindAsciiMath
object instance that will override the default one. This allows you to create a subclass ofFindAsciiMath
and pass that to the AsciiMath input jax. Anull
value means use the defaultFindAsciiMath
class and make a new instance of that.
Options Common to All Input Processors¶
There are no options that are common to all input jax, but a number of
the Document Options affect what portions of the document will
be processed by the input jax that scan the page for delimiters (i.e.,
TeX and AsciiMath). In particular, the options that correspond to the
version2 options skipTags
, includeTags
, and similar options
for the various v2 preprocessors are now documentlevel options.
Output Processor Options¶
There are a number of configuration options that are common to all the output processors. These are described following the links below, which give the options that are specific to the particular output jax.
CommonHTML Output Processor Options¶
The options below control the operation of the CommonHTML output
processor that is run when you include
'output/chtml'
in the load
array of the loader
block of
your MathJax configuration, or if you load a combined component that
includes the CommonHTML output jax. They are listed with their default
values. To set any of these options, include a chtml
section in
your MathJax
global object.
The Configuration Block¶
MathJax = {
chtml: {
scale: 1, // global scaling factor for all expressions
minScale: .5, // smallest scaling factor to use
mtextInheritFont: false, // true to make mtext elements use surrounding font
merrorInheritFont: true, // true to make merror text use surrounding font
mathmlSpacing: false, // true for MathML spacing rules, false for TeX rules
skipAttributes: {}, // RFDa and other attributes NOT to copy to the output
exFactor: .5, // default size of ex in em units
displayAlign: 'center', // default for indentalign when set to 'auto'
displayIndent: '0', // default for indentshift when set to 'auto'
matchFontHeight: true, // true to match exheight of surrounding font
fontURL: '[mathjax]/components/output/chtml/fonts/woffv2', // The URL where the fonts are found
adaptiveCSS: true // true means only produce CSS that is used in the processed equations
}
};
Option Descriptions¶

matchFontHeight: true
This setting controls whether MathJax will scale the mathematics so that the exheight of the math fonts matches the exheight of the surrounding fonts. This makes the math match the surroundings better, but if the surrounding font does not have its exheight set properly (and not all fonts do), it can cause the math to not match the surrounding text. While this will make the lowercase letters match the surrounding fonts, the upper case letters may not match (that would require the font height and exheight to have the same ratio in the surrounding text as in the math fonts, which is unlikely).

fontURL: '[mathjax]/components/output/chtml/fonts/woffv2'
This is the URL to the location where the MathJax fonts are stored. In the default,
[mathjax]
is replaced by the location from which you have loaded MathJax. You should include a complete URL to the location of the fonts you want to use.

adaptiveCSS: true
This setting controls how the CommonHTML output jax handles the CSS styles that it generates. When true, this means that only the CSS needed for the math that has been processed on the page so far is generated. When false, the CSS needed for all elements and all characters in the MathJax font are generated. This is an extremely large amount of CSS, and that can have an effect on the performance of your page, so it is best to leave this as
true
. You can reset the information about what CSS is needed by using the commandMathJax.startup.document.output.clearCache();
to clear the font cache.
The remaining options are described in the Options Common to All Output Processors section.
SVG Output Processor Options¶
The options below control the operation of the SVG output
processor that is run when you include 'output/svg'
in the load
array of the loader
block of your MathJax
configuration, or if you load a combined component that includes the
CommonHTML output jax. They are listed with their default values. To
set any of these options, include an svg
section in your
MathJax
global object.
The Configuration Block¶
MathJax = {
svg: {
scale: 1, // global scaling factor for all expressions
minScale: .5, // smallest scaling factor to use
mtextInheritFont: false, // true to make mtext elements use surrounding font
merrorInheritFont: true, // true to make merror text use surrounding font
mathmlSpacing: false, // true for MathML spacing rules, false for TeX rules
skipAttributes: {}, // RFDa and other attributes NOT to copy to the output
exFactor: .5, // default size of ex in em units
displayAlign: 'center', // default for indentalign when set to 'auto'
displayIndent: '0', // default for indentshift when set to 'auto'
fontCache: 'local', // or 'global' or 'none'
localID: null, // ID to use for local font cache (for single equation processing)
internalSpeechTitles: true, // insert <title> tags with speech content
titleID: 0 // initial id number to use for arialabeledby titles
}
};
Option Descriptions¶

fontCache: 'local'
This setting determines how the SVG output jax manages characters that appear multiple times in an equation or on a page. The SVG processor uses SVG paths to display the characters in your math expressions, and when a character is used more than once, it is possible to reuse the same path description; this can save space in the SVG image, as the paths can be quite complex. When set to
'local'
, MathJax will cache font paths on an expressbyexpression (each expression has its own cache within the SVG image itself), which makes the SVG selfcontained, but still allows for some savings if characters are repeated. When set to'global'
, a single cache is used for all paths on the page; this gives the most savings, but makes the images dependent on other elements of the page. When set to'none'
, no caching is done and explicit paths are used for every character in the expression.

internalSpeechTitles: true
This tells the SVG output jax whether to put speech text into
<title>
elements within the SVG (when set to'true'
), or to use anarialabel
attribute instead. Neither of these control whether speech strings are generated (that is handled by the SemanticEnrich Extension Options settings); this setting only tells what to do with a speech string when it has been generated or included as an attribute on the root MathML element.
The remaining options are described in the Options Common to All Output Processors section.
Developer Options¶
In addition to the options listed above, lowlevel options intended for developers include the following:

localID: null
This gives the ID prefix to use for the paths stored in a local font cache when
fontCache
is set to'local'
. This is useful if you need to process multiple equations by hand and want to generate unique ids for each equation, even if MathJax is restarted between equations. If set tonull
, no prefix is used.

titleID: 0
This gives the initial number used to make unique
<title>
ids wheninternalSpeechTitles
istrue
. This is useful if you need to process multiple equations by hand and want to generate unique ids for each equation, even if MathJax is restarted between equations.
Options Common to All Output Processors¶
The following options are common to all the output processors listed
above. They are given here with their default values, using the
chtml
block as an example.
MathJax = {
chtml: {
scale: 1, // global scaling factor for all expressions
minScale: .5, // smallest scaling factor to use
mtextInheritFont: false, // true to make mtext elements use surrounding font
merrorInheritFont: false, // true to make merror text use surrounding font
mtextFont: '', // font to use for mtext, if not inheriting (empty means use MathJax fonts)
merrorFont: 'serif', // font to use for merror, if not inheriting (empty means use MathJax fonts)
unknownFamily: 'serif', // font to use for character that aren't in MathJax's fonts
mathmlSpacing: false, // true for MathML spacing rules, false for TeX rules
skipAttributes: {}, // RFDa and other attributes NOT to copy to the output
exFactor: .5, // default size of ex in em units
displayAlign: 'center', // default for indentalign when set to 'auto'
displayIndent: '0' // default for indentshift when set to 'auto'
}
};
Note
The matchFontHeight
option is no longer available on the SVG
output processor, so it is no longer listed here. It is now
decribed among the CommonHTML output options.
Option Descriptions¶

scale: 1
The scaling factor for math compaired to the surrounding text. The CommonHTML output processor tries to match the exsize of the mathematics with that of the text where it is placed, but you may want to adjust the results using this scaling factor. The user can also adjust this value using the contextual menu item associated with the typeset mathematics.

minScale: .5
This gives a minimum scale factor for the scaling used by MathJax to match the equation to the surrounding text. This will prevent MathJax from making the mathematics too small.

mtextInheritFont: false
This setting controls whether
<mtext>
elements will be typeset using the math fonts or the font of the surrounding text. Whenfalse
, the mtextFont will be used, unless it is blank, in which case math fonts will be used, as they are for other token elements; whentrue
, the font will be inherited from the surrounding text, when possible, depending on themathvariant
for the element (some math variants, such asfraktur
can’t be inherited from the surroundings).

merrorInheritFont: false
This setting controls whether the text for
<merror>
elements will be typeset using the math fonts or the font of the surrounding text. Whenfalse
, the merrorFont will be used; whentrue
, the font will be inherited from the surrounding text, when possible, depending on themathvariant
for the element (some math variants, such asfraktur
can’t be inherited from the surroundings).

mtextFont: ''
This specifies the font family to use for
<mtext>
elements when mtextInheritFont isfalse
(and is ignored if it istrue
). It can be a commaseparated list of fontfamily names. If it is empty, then the math fonts are used, as they are with other token elements.

merrorFont: 'serif'
This specifies the font family to use for
<merror>
elements when merrorInheritFont isfalse
(and is ignored if it istrue
). It can be a commaseparated list of fontfamily names. If it is empty, then the math fonts are used, as they are with other token elements.

unknownFamily: 'serif'
This specifies the font family to use for characters that are not found in the MathJax math fonts. For exmaple, if you enter unicode characters directly, these may not be in MathJax’s font, and so they will be taken from the font specified here.

mathmlSpacing: false
This specifies whether to use TeX spacing or MathML spacing when typesetting the math. When
true
, MathML spacing rules are used; whenfalse
, the TeX rules are used.

skipAttributes: {}
This object gives a list of nonstandard attributes (e.g., RFDa attributes) that will not be transferred from MathML element to their corresponding DOM elements in the typeset output. For example, with
skipAttributes: { datamyattr: true }
a MathML element like
<mi datamyattr="some data">x</mi>
will not have thedatamyattr
attribute on the<mjxmi>
element created by the CommonHTML output processor to represent the<mi>
element (normally, any nonstandard attributes are retained in the output).

exFactor: .5
This is the size of an ex in comparison to 1 em that is to be used when the exsize can’t be determined (e.g., when running in a Node application, where the size of DOM elements can’t be determined).

displayAlign: 'center'
This determines how displayed equations will be aligned (left, center, or right). The default is
'center'
.

displayIndent: 0
This gives the amount of indentation that should be used for displayed equations. The default is
0
. A value of'1em'
, for example, would introduce an extra 1 em of space from whichever margin the equation is aligned to, or an offset from the center position if the expression is centered. Note that negative values are allowed.
Developer Options¶
In addition to the options listed above, lowlevel options intended for developers include the following:

wrapperFactory: null
The
WrapperFactory
object instance to use for creating wrappers for the internal MathML objects. This allows you to create a subclass ofWrapperFactory
and pass that to the output jax. Anull
value means use the defaultWrapperFactory
class and make a new instance of that.

font: null
The
FontData
object instance to use for creating wrappers for the internal MathML objects. This allows you to create a subclass ofFontData
and pass that to the output jax. Anull
value means use the defaultFontData
class and make a new instance of that.

cssStyles: null
The
CssStyles
object instance to use for creating wrappers for the internal MathML objects. This allows you to create a subclass ofCssStyles
and pass that to the output jax. Anull
value means use the defaultCssStyles
class and make a new instance of that.
Document Options¶
The options below control the operation of the MathDocument
object
created by MathJax to process the mathematics in your web page. They
are listed with their default values. To set any of these options,
include an options
section in your MathJax
global object.
The Configuration Block¶
MathJax = {
options: {
skipHtmlTags: [ // HTML tags that won't be searched for math
'script', 'noscript', 'style', 'textarea', 'pre',
'code', 'annotation', 'annotationxml'
],
includeHtmlTags: { // HTML tags that can appear within math
br: '\n'