LaTeX Math Syntax Guide

LaTeX is the standard for typesetting mathematical expressions in academic and technical writing. In Markdown, you can embed LaTeX math using dollar sign delimiters — $...$ for inline math and $$...$$ for display (block) math. MD Viewer renders math using KaTeX, a fast and accurate math typesetting library. This guide covers the most commonly used LaTeX commands.

Inline vs. Display Math

There are two ways to include math in your Markdown documents:

Inline math: The formula $E = mc^2$ appears within text. Display math (centered on its own line): $$ \int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2} $$

Inline math flows with your text and is useful for referencing variables or short expressions. Display math is centered and given its own vertical space, ideal for important equations you want to stand out.

Basic Arithmetic & Operators

DescriptionLaTeXOutput
Additiona + ba + b
Subtractiona - ba - b
Multiplicationa \times ba × b
Divisiona \div ba ÷ b
Plus-minus\pm±
Not equal\neq
Less than or equal\leq
Greater than or equal\geq
Approximately\approx

Fractions

Use \frac{numerator}{denominator} to create fractions:

$\frac{1}{2}$ — Simple fraction $\frac{x+1}{x-1}$ — Expression fraction $\frac{\partial f}{\partial x}$ — Partial derivative $\cfrac{1}{1+\cfrac{1}{2}}$ — Continued fraction

For inline fractions that appear too large, you can use \tfrac (text-style fraction) to keep them compact.

Superscripts and Subscripts

Use ^ for superscripts and _ for subscripts. Wrap multi-character expressions in curly braces:

$x^2$ — x squared $x^{n+1}$ — Multi-character exponent $a_i$ — Subscript $a_{i,j}$ — Multi-character subscript $x_i^2$ — Both subscript and superscript ${}_nC_r$ — Leading subscript

Greek Letters

LowercaseLaTeXUppercaseLaTeX
α\alphaAA
β\betaBB
γ\gammaΓ\Gamma
δ\deltaΔ\Delta
ε\epsilonEE
θ\thetaΘ\Theta
λ\lambdaΛ\Lambda
μ\muMM
π\piΠ\Pi
σ\sigmaΣ\Sigma
φ\phiΦ\Phi
ω\omegaΩ\Omega

Sums, Products, and Integrals

$$\sum_{i=1}^{n} x_i$$ — Summation $$\prod_{i=1}^{n} x_i$$ — Product $$\int_a^b f(x)\,dx$$ — Definite integral $$\iint_D f(x,y)\,dA$$ — Double integral $$\oint_C \vec{F} \cdot d\vec{r}$$ — Line integral $$\lim_{x \to \infty} f(x)$$ — Limit

The \, adds a thin space before dx, which is standard typographic practice in integrals.

Matrices

Create matrices with different bracket styles using environment commands:

$$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$$ — Round brackets $$\begin{bmatrix} a & b \\ c & d \end{bmatrix}$$ — Square brackets $$\begin{vmatrix} a & b \\ c & d \end{vmatrix}$$ — Determinant (pipes) $$\begin{matrix} a & b \\ c & d \end{matrix}$$ — No brackets

Use & to separate columns and \\ to start a new row. For larger matrices, you can use \cdots, \vdots, and \ddots for ellipses.

Common Functions

LaTeX provides named functions that render in upright (Roman) font rather than italic:

\sin, \cos, \tan, \cot, \sec, \csc \arcsin, \arccos, \arctan \ln, \log, \exp \min, \max, \sup, \inf \det, \dim, \ker, \gcd

Example usage: $\sin^2\theta + \cos^2\theta = 1$

Roots and Radicals

$\sqrt{x}$ — Square root $\sqrt[3]{x}$ — Cube root $\sqrt[n]{x}$ — nth root $\sqrt{x^2 + y^2}$ — Complex expression under radical

Brackets and Delimiters

Use \left and \right for auto-sizing brackets that grow with their content:

$\left( \frac{x}{y} \right)$ — Parentheses $\left[ \frac{x}{y} \right]$ — Square brackets $\left\{ \frac{x}{y} \right\}$ — Curly braces $\left| \frac{x}{y} \right|$ — Absolute value $\left\langle x, y \right\rangle$ — Angle brackets

Aligned Equations

Use the aligned environment for multi-line equations aligned at a specific point (usually the equals sign):

$$ \begin{aligned} f(x) &= x^2 + 2x + 1 \\ &= (x + 1)^2 \end{aligned} $$

The & marks the alignment point, and \\ creates a new line.

Cases (Piecewise Functions)

$$ f(x) = \begin{cases} x^2 & \text{if } x \geq 0 \\ -x & \text{if } x < 0 \end{cases} $$

Arrows and Notation

SymbolLaTeXSymbolLaTeX
\rightarrow\leftarrow
\Rightarrow\Leftarrow
\leftrightarrow\Leftrightarrow
\mapsto\infty
\nabla\partial
\in\notin
\subset\subseteq
\cup\cap
\forall\exists

Accents and Decorations

$\hat{x}$ — Hat (unit vector) $\bar{x}$ — Bar (mean) $\vec{x}$ — Vector arrow $\dot{x}$ — Single dot (time derivative) $\ddot{x}$ — Double dot (acceleration) $\tilde{x}$ — Tilde $\overline{AB}$ — Overline (segment) $\overbrace{x+y}^{\text{sum}}$ — Overbrace with label

Common Formulas Quick Reference

Quadratic formula: $$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$ Euler's identity: $$e^{i\pi} + 1 = 0$$ Binomial theorem: $$(x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k$$ Taylor series: $$f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n$$ Gaussian integral: $$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$

Try LaTeX math live — write equations in the MD Viewer editor or use our dedicated LaTeX editor for focused math work.

Open LaTeX Editor