Math
Mathematics is written in LaTeX, in two places: the :math: role for a
formula sitting inside a sentence, and the .. math:: directive for a
display equation on its own line.
Both are converted to MathML while the site is built. Nothing is rendered in the reader's browser by a script, so a page carries its own equations and needs no network to display them — and LaTeX the converter cannot read becomes a build warning rather than a silent failure on the page.
The :math: Role
Inline math flows with the surrounding text: the identity is Pythagoras' theorem, and Euler's relates five constants at once. Greek letters (, , ), subscripts () and fractions () all work.
Because the content is LaTeX, an angle bracket is an inequality and not the explicit-title syntax other roles use — means what it says.
The .. math:: Directive
The equation can be written as the directive's argument, for a short one:
Or as the directive's body, which is the usual form:
Several Equations at Once
A blank line separates two equations inside one directive. They are aligned with each other rather than rendered as separate blocks:
Multi-Line Equations
Within a single equation, \\ starts a new aligned line and & marks the
alignment point:
:label: and the :eq: Role
A :label: gives an equation a number and makes it referenceable. Only
labeled equations are numbered, and the numbering restarts in every document:
The :eq: role links to a labeled equation, showing its number as the link
text: the identity above is (1), and the summation is
(2). A reference resolves across documents too, so another page
can point at (1) just as this one does.
:name:
:name: is accepted as a spelling of :label:, and behaves identically:
That equation is (3).
:class:
Adds CSS class names to the rendered equation's wrapper, for a theme to style:
:nowrap:
Normally the directive wraps its body in an alignment environment as needed.
:nowrap: turns that off, so the author supplies the environment
themselves. An equation written this way is never numbered by rinx —
the numbering is the author's to write too, and an environment like align
numbers its own rows. That count restarts in every :nowrap: directive,
because each one is converted on its own:
Environments
Any environment the converter implements can be used, either through
:nowrap: or directly in the body.
Cases:
Matrices:
Stacked equations with gathered:
One deviation from Sphinx is worth knowing: Sphinx wraps a multi-line equation
in split, which the MathML converter does not implement, so aligned is
used instead. It produces the same alignment.