LaTeX Math
The <Latex> component renders mathematical expressions using KaTeX. Use it for equations, formulas, and any mathematical notation.
Note
In MDX, curly braces inside JSX content are parsed as JavaScript expressions. For LaTeX expressions containing curly braces (like \frac{a}{b}), use a JavaScript string literal: {'\\frac{a}{b}'}.
Basic Expressions#
Simple expressions without curly braces work directly:
<Latex>
Inline math sits in the sentence: sorting the index costs O(n \log n) comparisons.
Fractions and Derivatives#
For LaTeX with curly braces, wrap in a JS string literal:
<Latex>
<Latex>
Summation#
<Latex>
Integrals#
<Latex>
Normal Distribution#
<Latex>
Euler's Identity#
<Latex>
Using Strings vs Direct Content#
Direct content (works for simple expressions)
MDX
<Latex>a^2 + b^2 = c^2</Latex>
Works when the expression has no { or } characters.
String literal (required for complex expressions)
MDX
<Latex>{'\\frac{a}{b}'}</Latex>
Required when the expression contains {...} braces. Use \\ for backslashes in the string.
Props Reference#
| Prop | Type | Description |
|---|---|---|
children | string | LaTeX expression string. |
Note
KaTeX supports a large subset of LaTeX. See the KaTeX supported functions documentation for the complete list.
Was this page helpful?