1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
|
.. _tex-options:
###########################
TeX Input Processor Options
###########################
The options below control the operation of the :ref:`TeX input
processor <tex-input>` that is run when you include ``'input/tex'``,
``'input/tex-full'``, or ``'input/tex-base'`` 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 :data:`MathJax` global object.
-----
The Configuration Block
=======================
.. code-block:: javascript
MathJax = {
tex: {
packages: ['base'], // extensions to use
inlineMath: [ // start/end delimiter pairs for in-line 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: /^(?:[0-9]+(?:\{,\}[0-9]{3})*(?:\.[0-9]*)?|\.[0-9]+)/,
// 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: 10000, // 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
:ref:`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`` sub-block of the
``tex`` block. Version 3.2 includes code to move the configuration
from its old location to its new one, but that
backward-compatibility code will be removed in a future version.
-----
Option Descriptions
===================
.. _tex-packages:
.. describe:: packages: ['base']
This array lists the names of the packages that should be
initialized by the TeX input processor. The :ref:`input/tex
<tex-input>` and :ref:`input/tex-full <tex-input>` 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:
.. code-block:: javascript
MathJax = {
loader: {load: ['[tex]/enclose']},
tex: {
packages: {'[+]': ['enclose']}
}
};
This loads the :ref:`tex-enclose` extension and activates it by
including it in the package list.
You can remove packages from the default list using ``'[-]'``
rather than ``[+]``, as in the followiong example:
.. code-block:: javascript
MathJax = {
tex: {
packages: {'[-]': ['noundefined']}
}
};
This would disable the :ref:`tex-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:
.. code-block:: javascript
MathJax = {
loader: {load: ['[tex]/enclose']},
tex: {
packages: {'[-]': ['noundefined', 'autoload'], '[+]': ['enclose']}
}
};
This disables the :ref:`tex-noundefined` and :ref:`tex-autoload`
extensions, and adds in the :ref:`tex-enclose` extension.
.. _tex-inlineMath:
.. describe:: inlineMath: [['\\\(','\\\)']]
This is an array of pairs of strings that are to be used as
in-line 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,
.. code-block:: javascript
inlineMath: [ ['$','$'], ['\\(','\\)'] ]
would cause MathJax to look for ``$...$`` and ``\(...\)`` as
delimiters for in-line 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 less-than 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.
.. _tex-displayMath:
.. describe:: 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 less-than 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.
.. _tex-processEscapes:
.. describe:: 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 just before
in-line math). When ``false``, ``\$`` will not be altered, and
its dollar sign may be considered part of a math delimiter.
Typically this is set to ``true`` if you enable the ``$ ... $``
in-line delimiters, so you can type ``\$`` and MathJax will
convert it to a regular dollar sign in the rendered document.
.. _tex-processRefs:
.. describe:: processRefs: true
When set to ``true``, MathJax will process ``\ref{...}`` outside
of math mode.
.. _tex-processEnvironments:
.. describe:: processEnvironments: true
When ``true``, `tex2jax` looks not only for the in-line and
display math delimiters, but also for LaTeX environments
(``\begin{something}...\end{something}``) and marks them for
processing by MathJax. When ``false``, LaTeX environments will
not be processed outside of math mode.
.. _tex-digits:
.. describe:: digits: /^(?:[0-9]+(?:\{,\}[0-9]{3})*(?:\.[0-9]*)?|\.[0-9]+)/
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, use
.. code-block:: javascript
MathJax = {
tex: {
digits: /^(?:[0-9]+(?:\{,\}[0-9]*)?|\{,\}[0-9]+)/
}
};
.. _tex-tags:
.. describe:: 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 auto-numbering 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.
.. _tex-tagSide:
.. describe:: 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 left-hand side.
.. _tex-tagIndent:
.. describe:: 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.
.. _tex-useLabelIds:
.. describe:: useLabelIds: true
This controls whether element IDs for tags use the ``\label`` name
or the equation number. When ``true``, use the label, when
``false``, use the equation number.
.. _tex-maxMacros:
.. describe:: maxMacros: 10000
Because a definition of the form ``\def\x{\x} \x`` would cause MathJax
to loop infinitely, the ``maxMacros`` constant will limit the number of
macro substitutions allowed in any expression processed by MathJax.
.. _tex-maxBuffer:
.. describe:: 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, the ``maxBuffer`` 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.
.. raw:: html
<style>
.rst-content dl.describe > dt:first-child {
margin-bottom: 0;
}
.rst-content dl.describe > dt + dt {
margin-top: 0;
border-top: none;
padding-left: 6em;
}
.rst-content dl.describe > dt + dd {
margin-top: 6px;
}
</style>
.. _tex-baseURL:
.. describe:: 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.
.. _tex-formatError:
.. describe:: 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 a ``try/carch`` block).
The remaining options are described in the
:ref:`input-common-options` section.
-----
Developer Options
=================
In addition to the options listed above, low-level options intended
for developers include the following:
.. _tex-FindTeX:
.. describe:: FindTeX: null
The ``FindTeX`` object instance that will override the default
one. This allows you to create a subclass of ``FindTeX`` and
pass that to the TeX input jax. A ``null`` value means use the
default ``FindTeX`` class and make a new instance of that.
-----
.. _tex-extension-options:
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 :ref:`input/tex <tex-input>` 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 :ref:`tex-configmacros` package adds a ``macros``
block to the ``tex`` configuration block that allows you to pre-define
macros for use in TeX espressions:
.. code-block:: javascript
MathJax = {
tex: {
macros: {
R: '\\mathbf{R}'
}
}
}
The options for the various TeX packages (that have options) are
described in the links below:
* :ref:`tex-ams-options`
* :ref:`tex-amscd-options`
* :ref:`tex-autoload-options`
* :ref:`tex-color-options`
* :ref:`tex-configmacros-options`
* :ref:`tex-mathtools-options`
* :ref:`tex-noundefined-options`
* :ref:`tex-physics-options`
* :ref:`tex-require-options`
* :ref:`tex-setoptions-options`
* :ref:`tex-tagformat-options`
-----
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
:ref:`tex-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.
|-----|
|