Math
The math directive renders mathematical expressions using LaTeX syntax. Mathematical expressions are rendered client-side using KaTeX for fast, accurate display.
S(doc) = exp(\lambda \cdot max(0, |fieldvalue_{doc} - origin| - offset))
:::{math}
S(doc) = exp(\lambda \cdot max(0, |fieldvalue_{doc} - origin| - offset))
:::
For block-level mathematical expressions, use display math syntax:
\[
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
\]
:::{math}
\[
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
\]
:::
The directive automatically detects display math based on:
- LaTeX display delimiters:
\[and\] - TeX display delimiters:
$$and$$ - LaTeX environments:
\begin{...}and\end{...} - Multi-line expressions
- Complex expressions containing
\frac,\sum,\int,\lim, etc.
Label mathematical expressions for cross-referencing:
E = mc^2
:::{math}
:label: einstein-equation
E = mc^2
:::
This creates an element with id="einstein-equation" that can be referenced elsewhere in the document.
The math directive supports complex LaTeX expressions:
\begin{align}
\frac{\partial f}{\partial x} &= \lim_{h \to 0} \frac{f(x+h) - f(x)}{h} \\
\nabla \cdot \vec{E} &= \frac{\rho}{\epsilon_0}
\end{align}
:::{math}
\begin{align}
\frac{\partial f}{\partial x} &= \lim_{h \to 0} \frac{f(x+h) - f(x)}{h} \\
\nabla \cdot \vec{E} &= \frac{\rho}{\epsilon_0}
\end{align}
:::
The math directive supports most common LaTeX mathematical notation:
- Fractions:
\frac{numerator}{denominator} - Superscripts and subscripts:
x^2,x_i - Integrals:
\int,\iint,\iiint - Sums and products:
\sum,\prod - Limits:
\lim,\limsup,\liminf - Greek letters:
\alpha,\beta,\gamma, etc. - Matrices:
\begin{matrix},\begin{pmatrix}, etc. - Aligned equations:
\begin{align},\begin{eqnarray} - Roots:
\sqrt{x},\sqrt[n]{x} - Operators:
\sin,\cos,\log,\exp, etc.