Skip to content
Do Ngoc Tuan (Mason Do)

Math rendering reference

Reference post that exercises every LaTeX case the site must render: inline, display, aligned, matrices, sums, integrals.

  • meta
  • math

This post is the acceptance test for the math pipeline (FR-304). If anything below looks wrong, the build is broken.

Inline math

Euler’s identity eiπ+1=0e^{i\pi} + 1 = 0 sits inside a sentence. A vector x∈Rnx \in \R^n uses the custom \R macro, and E[X]=μ\mathbb{E}[X] = \mu uses \mathbb. Fractions inline: ab\frac{a}{b}.

Display math

∫−∞∞e−x2 dx=π\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi} ∑k=1nk=n(n+1)2,∏i=1n(1+1i)=n+1\sum_{k=1}^{n} k = \frac{n(n+1)}{2}, \qquad \prod_{i=1}^{n} \left(1 + \frac{1}{i}\right) = n + 1

Aligned equations

∇⋅E=ρε0∇×B=μ0J+μ0ε0∂E∂t\begin{aligned} \nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\ \nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \end{aligned}

Matrices

A=(a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮am1am2⋯amn),det⁡[abcd]=ad−bcA = \begin{pmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{pmatrix}, \qquad \det \begin{bmatrix} a & b \\ c & d \end{bmatrix} = ad - bc

A very long equation

On a phone this should scroll sideways inside its own box, while the page itself stays put:

f(x)=a0+a1x+a2x2+a3x3+a4x4+a5x5+a6x6+a7x7+a8x8+a9x9+a10x10+a11x11+a12x12f(x) = a_0 + a_1 x + a_2 x^2 + a_3 x^3 + a_4 x^4 + a_5 x^5 + a_6 x^6 + a_7 x^7 + a_8 x^8 + a_9 x^9 + a_{10} x^{10} + a_{11} x^{11} + a_{12} x^{12}

Things that must not become math

  • Price is $20, and another item costs $35.
  • Inline code keeps dollars literal: echo $HOME and cost = $5.
# Code blocks are highlighted by Shiki (min-light), dollars untouched
price = "$20"
def mean(xs):
    return sum(xs) / len(xs)

Tables and footnotes (GFM)

SymbolMeaning
R\Rreal numbers
∇\nablagradient

KaTeX runs at build time, so this page ships no math JavaScript.1

Footnotes

  1. Only the KaTeX stylesheet and fonts are loaded, and only on pages that contain math. ↩

← All posts