Source vs. output
Markdown + KaTeX comparison
In .md blog posts, wrap math with $...$ (inline) or $$...$$ (display).
In .astro files, use the <Math /> component for the same LaTeX strings.
Syntax reference
| Context | Inline | Display (block) |
|---|---|---|
| Markdown | $E = mc^2$ | $$\int_0^1 x\,dx$$ |
| Astro component | <Math tex="E = mc^2" /> | <Math tex="..." display /> |
Inline math in a sentence
Markdown / LaTeX
The golden ratio $\varphi$ satisfies $\varphi^2 = \varphi + 1$. Rendered (KaTeX)
Display equation (block)
Markdown / LaTeX
$$e^{i\pi} + 1 = 0$$ Rendered (KaTeX)
Fractions and roots
Markdown / LaTeX
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$ Rendered (KaTeX)
Summation and integrals
Markdown / LaTeX
$$\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}, \quad \int_0^1 x^2\,dx = \frac{1}{3}$$ Rendered (KaTeX)
Mandelbrot iteration
Markdown / LaTeX
$$z_{n+1} = z_n^2 + c, \quad z_0 = 0$$ Rendered (KaTeX)
Polar curve (rose)
Markdown / LaTeX
$$r = a\cos(k\theta) \quad \text{(rose curve)}$$ Rendered (KaTeX)
Using the Math component in .astro
Markdown / LaTeX
<Math tex="\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}" display /> Rendered (KaTeX)