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.
Options Common to All Output Processors
The following options are common to all the output processors listed
above. These can be specified in the output block of your
MathJax configuration (they apply to any output jax), or can be
included in the configuration for the specific output jax that you are
using. It is best to use the output section for these
options, since then if your reader uses the MathJax contextual menu to
switch renderers, they will apply to the new renderer as well.
The options are given here with their default values.
MathJax = {
output: {
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'
displayOverflow: 'overflow', // default for overflow (scroll/scale/truncate/elide/linebreak/overflow)
linebreaks: { // options for when overflow is linebreak
inline: true, // true for browser-based breaking of inline equations
width: '100%', // a fixed size or a percentage of the container width
lineleading: .2, // the default lineleading in em units
},
font: '', // the font component to load
fontPath: FONTPATH, // The path to the font definitions
fontExtensions: [], // The font extensions to load
htmlHDW: 'auto', // 'use', 'force', or 'ignore' data-mjx-hdw attributes
preFilters: [], // A list of pre-filters to add to the output jax
postFilters: [], // A list of post-filters to add to the output jax
}
};
Note
The matchFontHeight option is no longer available on the SVG
output processor, so it is no longer listed here. It is now
described among the CommonHTML output options.
Other options specific to an output renderer are listed in the sections linked at the top of this page.
Option Descriptions
- scale: 1
The scaling factor for math compared to the surrounding text. The MathJax output processors try to match the ex-size of the mathematics with that of the text where it is placed, so that the lower-case letters in the mathematics are the same height as lower-case letters in the surrounding text. Note that this may mean that upper-case letters in the mathematics may not match those in the surrounding font, as not all fonts have the same height ratio between upper- and lower-case letters. You may want to adjust the results using this scaling factor to suit your situation. 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 themathvariantfor the element (some math variants, such asfrakturcan’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 themathvariantfor the element (some math variants, such asfrakturcan’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 comma-separated list of font-family 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 comma-separated list of font-family 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 example, if you enter unicode characters directly, these may not be in MathJax’s font, and so they will be taken from the font or fonts specified here.
- mathmlSpacing: false
This specifies whether to use TeX spacing or MathML spacing rules when typesetting the math. When
true, MathML spacing rules are used; whenfalse, the TeX rules are used.
- skipAttributes: {}
This object gives a list of non-standard 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: { 'data-my-attr': true }
a MathML element like
<mi data-my-attr="some data">x</mi>will not have thedata-my-attrattribute on the<mjx-mi>element created by the CommonHTML output processor to represent the<mi>element (normally, any non-standard 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 ex-size 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.
- displayOverflow: 'overflow'
This specifies how displayed equations that are too wide for their containers should be treated. The possible values are:
'scroll'to use a horizontal scroll bar to allow the rest of the equation scroll into view.'scale'to scale the equation until it fits into its container.'truncate'to clip the expression at the container size.'elide'is not yet implemented.'linebreak'to insert line breaks to keep the expression within the container.'overflow', to allow the expression to overflow the width of the container. This is the default.
Note that this option sets the
overflowattribute of the underlying MathML expression, if there isn’t one already.The user can change this value globally using the MathJax contextual menu.
- linebreaks: {...}
This block of options controls the line-breaking that is performed when the
displayOverflowis set to'linebreak'or the user selects linebreaking in the MathJax contextual menu. The options include:- inline: true
When set to true, in-line equations will be allowed to break (at locations that TeX would allow for linebreaks). The browser will then break the mathematics when needed, if the expression extends beyond the container’s width.
- width: '100%'
Gives the width for where displayed equations should be broken, either as a fixed size (e.g.
'500px'or'20em'), or as a percentage of the container’s width (e.g., the default value of'100%').
- lineleading: .2
The amount of extra vertical space, in em units, to be inserted between the lines of a displayed equation when it is broken.
Note that in-line breaks can change when the window size changes, since they are handled by the browser; but displayed equations are broken when initially typeset, and the breaks are not altered after that unless you explicitly rerender the equation.
See the Automatic Line Breaking section for more details on controlling line breaking within expressions.
- font: ''
This specifies the font to use from among the fonts available in MathJax, either as a name like
mathjax-stix2or as a path to the font npm package, likehttps://cdn.jsdelivr.net/npm/@mathjax/mathjax-stix2-font@4for in-browser use, or@mathjax/mathjax-stix2-fontfor use in node.See the MathJax Font Support section for more details about the fonts available and how to use them.
- fontPath: FONTPATH
This specifies the path for locating fonts by name. The default is
https://cdn.jsdelivr.net/npm/@mathjax/%%FONT%%-fontin the MathJax components for the browser, and@mathjax/%%FONT%%-fontin node applications. Any occurrences of%%FONT%%in the path will be replaced by the font name when the font is accessed.
- fontExtensions: []
This gives a list of font extensions to load when the output jax is loaded. For example, setting this to
['mathjax-euler']would load the euler font extension.
- htmlHDW: 'auto'
This controls how MathJax handles the size of HTML code embedded in your mathematics when its top-level element has an
data-mjx-hdwattribute that gives the size of the content. The possible values are:'ignore'to ignore the value ofdata-mjs-hdw.'force'to use thedata-mjx-hdwvalues to surround the HTML with additional nodes that force the HTML to have the given dimensions. (This makes the result in node and the browser always be the same.)'use'to assume thedata-mjx-hdwvalues are correct so that MathJax will use them in its size computations without forcing the HTML to have the given dimensions.'auto'to allow MathJax to determine which option to use; this will beignorewhen in the browser andforcewhen in node applications.
See Specifying the size of HTML in Expressions for more information, and for a tool for computing the values to use for the
data-mjx-hdwattributes.
- preFilters: []
This specifies a list of functions to run as pre-filters for the output jax. Each entry is either a function, or an array consisting of a function followed by a number, which is the priority of the pre-filter (lower priorities run first). The functions are passed an object with three properties:
math, giving theMathItembeing processed,documentgiving theMathDocumentfor the math item, anddatagiving themjx-containerDOM node for the math (empty at this point). The pre-filters are executed when the output jax is asked to typeset an expression, but before typesetting has occurred. The pre-filters can be used to adjust the internal MathML before any output is produced; the math item’srootproperty holds the internal structure.See the MathJax Pre- and Post-Filters section for examples of pre-filters.
- postFilters: []
This specifies a list of functions to run as post-filters for the TeX input jax. Each entry is either a function, or an array consisting of a function followed by a number, which is the priority of the pre-filter (lower priorities run first). The functions are passed an object with three properties:
math, giving theMathItembeing processed,documentgiving theMathDocumentfor the math item, anddatagiving themjx-containerDOM node for the math. The pre-filters are executed when the output jax has completed typesetting the expression into DOM elements, but before other actions involving the DOM tree for the expression (such as adding event handlers, adding speech, inserting it into the page, etc.) have occurred. Themjx-containernow holds the DOM tree for the typeset math.See the MathJax Pre- and Post-Filters section for examples of post-filters.
Developer Options
In addition to the options listed above, low-level options intended for developers include the following:
- wrapperFactory: null
The
WrapperFactoryobject instance to use for creating wrappers for the internal MathML objects. This allows you to create a subclass of theWrapperFactoryclass, make an instance of it, and pass and instance of that to the output jax to use in place of the usual one. Anullvalue means use the defaultWrapperFactoryclass and make a new instance of that.
- fontData: null
The
FontDataobject instance to use for the font to use. This is usually obtained from a font package, such asMathJaxNewcmFontimported from@mathjax/mathjax-newcm-font/js/chtml.js. This allows you to override the default font with a different one. It is also possible to subclass one of the MathJax fonts, make an instance of that, and pass that to the output jax to use in place of its usual one. Anullvalue means use the defaultFontDataclass (themathjax-newcmfont) and make a new instance of that.
- cssStyles: null
The
CssStylesobject instance to use for collecting the CSS styles from the various MathML classes, the font, and so on. This allows you to create a subclass of theCssStylesclass, make an instance of it, and pass that to the output jax in place of the usual one. Anullvalue means use the defaultCssStylesclass and make a new instance of that.
- linebreaks.LinebreakVisitor: null
The
LinebreakVisitorobject class to use for breaking long displayed equations. This allows you to create a subclass of theLinebreakVisitorclass and pass that to the output jax in place of the usual one. MathJax will make an instance of the class you pass it, or of its default class if this value isnull.