Math (KaTeX)
Write mathematical equations and formulas using LaTeX syntax, rendered with KaTeX. Available on all plans.
Overview
KaTeX is a fast math typesetting library that renders LaTeX syntax to beautiful equations. Unmarkdown supports both inline and block math expressions. KaTeX is available on all plans with no restrictions.
Inline Math
Wrap LaTeX expressions in single dollar signs to render inline math, which flows naturally within a paragraph.
The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ where $a \neq 0$.
The area of a circle is $A = \pi r^2$.Block Math
Use double dollar signs for display-mode equations that render as centered blocks on their own line.
$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$You can also use a fenced code block with the math language identifier:
```math
\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}
```Common Syntax
Frequently used KaTeX commands:
- Fractions: \frac{numerator}{denominator}
- Exponents and subscripts: x^2, x_i, x_{n+1}
- Square roots: \sqrt{x}, \sqrt[3]{x}
- Greek letters: \alpha, \beta, \gamma, \theta, \pi, \sigma, \lambda, \omega
- Summation: \sum_{i=1}^{n} x_i
- Products: \prod_{i=1}^{n} x_i
- Integrals: \int_{a}^{b}, \iint, \oint
- Limits: \lim_{x \to \infty} f(x)
Matrices
Several matrix environments are supported with different bracket styles:
Parentheses: $\begin{pmatrix} a & b \\ c & d \end{pmatrix}$
Brackets: $\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}$
No brackets: $\begin{matrix} a & b \\ c & d \end{matrix}$Piecewise Functions
Use the cases environment for piecewise-defined functions.
$$
f(x) = \begin{cases}
x^2 & \text{if } x \geq 0 \\
-x & \text{if } x < 0
\end{cases}
$$Aligned Equations
Use the aligned environment to align multi-line equations at a specific point (usually the equals sign).
$$
\begin{aligned}
2x + 3y &= 7 \\
x - y &= 1
\end{aligned}
$$Edge Cases
Dollar Signs in Non-Math Contexts
To display a literal dollar sign without triggering math mode, escape it with a backslash.
The price is \$9.99 per month.Math in Table Cells
Inline math works inside table cells. Use single dollar signs.
| Function | Formula |
|----------|---------|
| Area | $A = \pi r^2$ |
| Volume | $V = \frac{4}{3}\pi r^3$ |Math in Headings
Inline math can be used in headings, though complex expressions may affect heading readability.
## The $\chi^2$ DistributionBidirectional Editing
When editing in the preview pane, KaTeX equations preserve their LaTeX source via the data-latex attribute. This means equations round-trip correctly between the markdown editor and the visual preview without losing the original LaTeX syntax.
Reference
KaTeX supports most standard LaTeX math commands. For a complete list of supported functions, operators, and symbols, see the KaTeX supported functions reference.