skipLink.label

KaTeX Examples

This page collects KaTeX examples so that authors can quickly validate typography and the shared macro set. Every block below renders server-side via remark-math and rehype-katex with copy-paste friendly MathML and TeX.

Inline vs display

heading.anchorLabel

Inline math keeps equations in the flow of text, such as E=mc2E=mc^2 or the unit vector n^\vu{n}. Display math is set apart for emphasis:

F=ma\vb{F} = m \vb{a}

Use \ifrac{a}{b} or \tfrac{a}{b} for inline fractions like ab\ifrac{a}{b} and \frac{a}{b} for display:

12mv2+mgh=const\frac{1}{2}mv^2 + mgh = \text{const}

Limits and derivatives

heading.anchorLabel

The macros include differential operators for concise notation:

  • Velocity: drdt\dv{\vb{r}}{t}
  • Heat flow: Qt\pdv{Q}{t}
  • Gradient: T\grad T
  • Divergence: E\divergence \vb{E}
  • Curl: ×B\curl \vb{B}

A standard limit rendered with left-aligned display math:

limx0sinxx=1\lim_{x \to 0} \frac{\sin x}{x} = 1

Matrices and vectors

heading.anchorLabel
v=(vxvyvz),A=[210131014]\vb{v} = \begin{pmatrix} v_x \\ v_y \\ v_z \end{pmatrix}, \quad \mathbf{A} = \begin{bmatrix} 2 & 1 & 0 \\ 1 & 3 & -1 \\ 0 & -1 & 4 \end{bmatrix}

Vectors in inline math look like p\vb{p} while unit vectors such as z^\vu{z} keep the hat aligned with the bold letter.

Absolute values, norms, and delimiters

heading.anchorLabel
v=v=vx2+vy2+vz2,(E=mc2),[0tT],{xR}\abs{\vb{v}} = \norm{\vb{v}} = \sqrt{v_x^2 + v_y^2 + v_z^2}, \qquad \qty{E = mc^2}, \quad \qtyb{0 \leq t \leq T}, \quad \qtyc{ x \in \R }

Graphing island

heading.anchorLabel

The <Graph2D /> component renders lightweight function plots on the client using Plotly. Expressions are parsed with expr-eval so authors can experiment with quick sketches:

Try a polynomial with asymptotes:

Copy the original TeX

heading.anchorLabel

Thanks to the copy-tex plugin, selecting 0πsinxdx\int_0^{\pi} \sin x\,\dd x in the rendered output copies the raw TeX (\int_0^{\pi} \sin x\,\dd x). This makes it easy to reuse formulas across lectures without retyping them.

Keep this gallery handy when tuning future typography or testing new macros.