Back to Blog
Advanced

Writing Advanced Mathematical Formulas with KaTeX

Master complex mathematical notation in Markdown. From matrices to integrals, learn how to write publication-ready equations.

J

Jacky

March 25, 2026 15 min read

KaTeX is a fast, server-side mathematical rendering library that brings publication-quality math to Markdown. If you're writing technical documentation, research papers, or educational content, mastering KaTeX is essential.

Getting Started with Inline Math

Inline math is wrapped in single dollar signs: $formula$. For example, $E = mc^2$ renders as the famous energy-mass equivalence equation.

Display Math

For larger equations that deserve their own line, use double dollar signs:

$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$

Fractions

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

$$
\frac{d}{dx}\left( \int_{a}^{x} f(t)\,dt \right) = f(x)
$$

Matrices

KaTeX supports matrix environments:

$$
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
$$

Greek Letters

Greek letters are indispensable in math notation:

  • \alpha → α
  • \beta → β
  • \gamma → γ
  • \sigma → σ
  • \Sigma → Σ (uppercase)

Summations and Products

$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$

Subscripts and Superscripts

Use _ for subscripts and ^ for superscripts: x_{i}^{2} renders as x with subscript i and superscript 2.

Tips for Clean Equations

  • Use \left( and \right) for auto-sizing parentheses
  • Use \, for thin spaces in integrals
  • Use \text{label} for text within math environments
  • Preview your equations as you write — most editors with KaTeX support show live previews