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.
Inline & Display Math
Use single dollar signs $...$ for inline math and double dollar signs $$...$$ for display (block) equations.
Inline math flows within a sentence.
Inline: The equation $E = mc^2$ changed physics.
Display math is centered and gets its own vertical space.
Display equation on its own line:
$$
\int_{0}^{\infty} e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}
$$Greek Letters
Lowercase with a backslash, uppercase by capitalising the first letter.
$\alpha, \beta, \gamma, \delta, \epsilon, \theta, \lambda, \mu, \pi, \sigma, \phi, \omega$ $\Gamma, \Delta, \Theta, \Lambda, \Sigma, \Phi, \Omega$
Operators & Relations
$\pm \, \times \, \div \, \cdot \, \neq \, \approx \, \leq \, \geq \, \ll \, \gg \, \equiv \, \sim \, \propto \, \infty$
Fractions & Binomials
Fraction: $\frac{a}{b}$ or display:
$$
\frac{n!}{k!(n-k)!}
$$Binomial coefficient: $\binom{n}{k} = \frac{n!}{k!(n-k)!}$Use \\cfrac for continued fractions (keeps numerator centered).
Continued fraction:
$$
x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3}}}
$$Superscripts & Subscripts
Use ^ for superscripts and _ for subscripts. Wrap multi-character exponents in braces.
$x^2$, $x^{n+1}$, $x_i$, $x_{i,j}$, $x_i^2$, $_{10}^{235}\text{U}$Roots
Square root with \\sqrt{}, nth root with \\sqrt[n]{}.
$\sqrt{x}$, $\sqrt[3]{x}$, $\sqrt{x^2 + y^2}$Sums, Products & Integrals
$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$$$
\prod_{i=1}^{n} i = n!
$$Single, double, and contour integrals.
$$
\int_{a}^{b} f(x) \, dx \qquad \iint_{D} f(x,y) \, dA \qquad \oint_{C} \mathbf{F} \cdot d\mathbf{r}
$$Limits
$$
\lim_{x \to 0} \frac{\sin x}{x} = 1
$$Use \\left( and \\right) for auto-sizing parentheses.
$$
\lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n = e
$$Matrices
Use pmatrix (parentheses), bmatrix (brackets), vmatrix (determinant), or plain matrix.
$$
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}
$$Aligned Equations
Use aligned to align multiple equations at the & symbol.
$$
\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}
$$Sets & Logic
Common set and logic symbols, plus number set blackboard bold.
$\in, \notin, \subset, \subseteq, \cup, \cap, \emptyset, \forall, \exists, \neg, \land, \lor$
$\mathbb{R}, \mathbb{Z}, \mathbb{N}, \mathbb{Q}, \mathbb{C}$Set builder notation.
$$
A = \{ x \in \mathbb{R} \mid x^2 < 4 \}
$$Accents & Decorations
$\hat{x}, \bar{x}, \vec{v}, \dot{x}, \ddot{x}, \tilde{x}, \widehat{ABC}, \overline{AB}, \underline{text}$Spacing
LaTeX manages spacing automatically, but you can fine-tune it.
Use \\, \\; \\quad \\qquad for increasing amounts of space.
$a \, b$ (thin) vs $a \; b$ (medium) vs $a \quad b$ (wide) vs $a \qquad b$ (extra wide)
Text in Math
Use \\text{} to include normal text inside math mode.
$$
f(x) = x^2 \quad \text{for all } x \in \mathbb{R}
$$Colors
Use \\textcolor{color}{...} for colored math.
$$
\textcolor{blue}{\text{blue}} + \textcolor{red}{\text{red}} = \textcolor{purple}{\text{purple}}
$$Ready to write math?
Open the dedicated math editor with a symbol palette and formula templates.
Open LaTeX Math Editor