LaTeX Math in Markdown

A comprehensive guide to writing math equations in markdown using LaTeX syntax. Every example can be tried instantly in the editor.

Try it live: Open the LaTeX Math Editor or the Markdown Editor to try any of these examples. Math rendering is powered by KaTeX.

Inline & Display Math

Use single dollar signs $...$ for inline math and double dollar signs $$...$$ for display (block) equations.

Inline math flows within a sentence.

Markdown
Inline: The equation $E = mc^2$ changed physics.
Rendered
Loading preview...

Display math is centered and gets its own vertical space.

Markdown
Display equation on its own line:

$$
\int_{0}^{\infty} e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}
$$
Rendered
Loading preview...

Greek Letters

Lowercase with a backslash, uppercase by capitalising the first letter.

Markdown
$\alpha, \beta, \gamma, \delta, \epsilon, \theta, \lambda, \mu, \pi, \sigma, \phi, \omega$

$\Gamma, \Delta, \Theta, \Lambda, \Sigma, \Phi, \Omega$
Rendered
Loading preview...

Operators & Relations

Markdown
$\pm \, \times \, \div \, \cdot \, \neq \, \approx \, \leq \, \geq \, \ll \, \gg \, \equiv \, \sim \, \propto \, \infty$
Rendered
Loading preview...

Fractions & Binomials

Markdown
Fraction: $\frac{a}{b}$ or display:

$$
\frac{n!}{k!(n-k)!}
$$
Rendered
Loading preview...
Markdown
Binomial coefficient: $\binom{n}{k} = \frac{n!}{k!(n-k)!}$
Rendered
Loading preview...

Use \\cfrac for continued fractions (keeps numerator centered).

Markdown
Continued fraction:

$$
x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3}}}
$$
Rendered
Loading preview...

Superscripts & Subscripts

Use ^ for superscripts and _ for subscripts. Wrap multi-character exponents in braces.

Markdown
$x^2$, $x^{n+1}$, $x_i$, $x_{i,j}$, $x_i^2$, $_{10}^{235}\text{U}$
Rendered
Loading preview...

Roots

Square root with \\sqrt{}, nth root with \\sqrt[n]{}.

Markdown
$\sqrt{x}$, $\sqrt[3]{x}$, $\sqrt{x^2 + y^2}$
Rendered
Loading preview...

Sums, Products & Integrals

Markdown
$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$
Rendered
Loading preview...
Markdown
$$
\prod_{i=1}^{n} i = n!
$$
Rendered
Loading preview...

Single, double, and contour integrals.

Markdown
$$
\int_{a}^{b} f(x) \, dx \qquad \iint_{D} f(x,y) \, dA \qquad \oint_{C} \mathbf{F} \cdot d\mathbf{r}
$$
Rendered
Loading preview...

Limits

Markdown
$$
\lim_{x \to 0} \frac{\sin x}{x} = 1
$$
Rendered
Loading preview...

Use \\left( and \\right) for auto-sizing parentheses.

Markdown
$$
\lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n = e
$$
Rendered
Loading preview...

Matrices

Use pmatrix (parentheses), bmatrix (brackets), vmatrix (determinant), or plain matrix.

Markdown
$$
A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \quad
B = \begin{bmatrix} a & b \\ c & d \end{bmatrix} \quad
\det(A) = \begin{vmatrix} 1 & 2 \\ 3 & 4 \end{vmatrix}
$$
Rendered
Loading preview...

Aligned Equations

Use aligned to align multiple equations at the & symbol.

Markdown
$$
\begin{aligned}
(a + b)^2 &= a^2 + 2ab + b^2 \\
(a - b)^2 &= a^2 - 2ab + b^2 \\
(a + b)(a - b) &= a^2 - b^2
\end{aligned}
$$
Rendered
Loading preview...

Sets & Logic

Common set and logic symbols, plus number set blackboard bold.

Markdown
$\in, \notin, \subset, \subseteq, \cup, \cap, \emptyset, \forall, \exists, \neg, \land, \lor$

$\mathbb{R}, \mathbb{Z}, \mathbb{N}, \mathbb{Q}, \mathbb{C}$
Rendered
Loading preview...

Set builder notation.

Markdown
$$
A = \{ x \in \mathbb{R} \mid x^2 < 4 \}
$$
Rendered
Loading preview...

Accents & Decorations

Markdown
$\hat{x}, \bar{x}, \vec{v}, \dot{x}, \ddot{x}, \tilde{x}, \widehat{ABC}, \overline{AB}, \underline{text}$
Rendered
Loading preview...

Spacing

LaTeX manages spacing automatically, but you can fine-tune it.

Use \\, \\; \\quad \\qquad for increasing amounts of space.

Markdown
$a \, b$ (thin) vs $a \; b$ (medium) vs $a \quad b$ (wide) vs $a \qquad b$ (extra wide)
Rendered
Loading preview...

Text in Math

Use \\text{} to include normal text inside math mode.

Markdown
$$
f(x) = x^2 \quad \text{for all } x \in \mathbb{R}
$$
Rendered
Loading preview...

Colors

Use \\textcolor{color}{...} for colored math.

Markdown
$$
\textcolor{blue}{\text{blue}} + \textcolor{red}{\text{red}} = \textcolor{purple}{\text{purple}}
$$
Rendered
Loading preview...

Ready to write math?

Open the dedicated math editor with a symbol palette and formula templates.

Open LaTeX Math Editor
Send us feedback