Skip to main content

Math

There are two forms: inline $…$ and a block <math>. Both use the same small reader and the same box model, so a fraction stacks wherever it appears.

<p>The estimate $S_i$ is carried per site.</p>

<math>
\bar{S} &= \frac{1}{n}\sum_{i=1}^{n} S_i \label{eq-mean} \\
\sigma^2 &= \frac{1}{n-1}\sum_{i=1}^{n}\left(S_i - \bar{S}\right)^2 \label{eq-var}
</math>

Display blocks​

A <math> block is always display math.

  • \\ ends a row.
  • & separates cells in a row. Cells are set in columns, so &= aligns the equals signs.
  • \label{id} on a row names that row as an equation target.
<math>
a &= b + c \label{eq-sum} \\
d &= e - f \label{eq-diff}
</math>

Each labelled row is its own equation. A block of rows numbered once is not supported.

Numbering​

A labelled row is numbered, and the number is drawn by compile at the right edge of the block, vertically centred on its row, in parentheses. The printed form comes from numbering.equations:

{
"numbering": {
"equations": { "scope": "section" }
}
}

A row with no \label has no number and cannot be pointed at.

\tag{…} supplies the printed tag for a row instead of the computed number. This is useful for a one-off (★), but a tagged row still needs a \label to be a target.

Referring to an equation​

The label is written into the equations store, so a component can print it:

from "./gen/eq.g.mtx" import type { Equation };
from "./gen/eq.g.mtx" import const { equations };

export component CiteEq {
prop to: Equation;
return <a to={to}>({equations[to].label})</a>;
}
The variance in <CiteEq to="eq-var" /> is what the gather costs to maintain.

The link resolves after drawing, like every other internal link.

What the reader understands​

This is not TeX. It is a deliberately small notation for the formulas the document classes need.

Structure​

SyntaxMeaning
{…}Group
\frac{a}{b}Stacked fraction
\sqrt{x}, \sqrt[n]{x}Radical, with optional index
\bar{x}, \overline{x}Overline
\left( … \right)Fence that grows with its contents; \left. for an empty side
x_i, x^2, x_i^2Scripts
\, \; \:Spaces
\text{…}, \mathrm{…}, \operatorname{…}A group set as text

\mathrm and \text group their argument; they do not switch the face. There is no bold or italic inside math beyond what the math face provides.

Greek​

\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \kappa \lambda \mu \nu \xi \pi \rho \sigma \tau \upsilon \phi \chi \psi \omega, and the uppercase forms \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Phi \Psi \Omega.

Operators and relations​

\sum \prod \int \partial \nabla \infty

\pm \times \cdot \ldots / \dots \to / \rightarrow \leftarrow \in \approx \propto \ge / \geq \le / \leq \ne / \neq

Functions​

\sin \cos \tan \cot \sec \csc \arcsin \arccos \arctan \log \ln \exp \lim \min \max \arg \det \dim \ker \hom \deg

Large operators — \sum, \prod — put scripts above and below rather than to the right.

Escaping​

Markup does not apply inside math, so a < b needs no escaping. Four characters are special:

WrittenPrints
\$$
\&&
\\A row break (not a backslash)
\label{…}A label, not text

An unknown command is reported as math-command and its literal source is drawn. The engine does not silently drop it.

The math face​

Math is set in the face declared with the family name math:

{
"font": {
"faces": [
{ "family": "math", "path": "assets/STIXTwoMath-Regular.otf" }
]
}
}

If no math family is declared, the default face is used. A glyph the face cannot draw is reported as missing-glyph; the engine does not substitute a lookalike silently.