scverse_doc.math_core#

Math rendering via math-core.

Browsers support MathML today, so math-core is the most lightweight way to render math on the web.

Examples

Inline math, and a block equation referenced via its :label::

:math:`e^{i\pi} = -1`, see :eq:`math-example`.

..  math::
    :label: math-example

    \operatorname{AA}(c_\text{fg}, c_\text{bg}) \geq 4.5

eiπ=−1, see (1).

(1)#AA⁡(cfg,cbg)≥4.5

Equations separated by blank lines, or rows separated by \\, are aligned at &:

..  math::

    a &= b + c

    d &= e
a=b+cd=e

:no-wrap: passes the LaTeX as is, e.g. for your own environment:

..  math::
    :no-wrap:

    \begin{cases} 1 & x > 0 \\ 0 & \text{otherwise} \end{cases}
{1x>00otherwise⁣

Configure the converter, e.g. with your own macros, via math_core_options. math-core’s mathmlfixes.css is included, mainly to fix Chromium’s rendering.

Configuration#

math_core_options#
Type:
dict
Default:
{}

Keyword arguments for math-core’s LatexToMathML, e.g. macros (named without the backslash, arguments as #1 etc.):

math_core_options = dict(
    macros={"R": r"\mathbb{R}", "vec": r"\mathbf{#1}"},
)