aka LaTeX, KaTeX, MathJAX
Install dependencies
pnpm add katex rehype-katex remark-math
Configure Astro
import remarkMath from "remark-math";import rehypeKatex from "rehype-katex"; export default defineConfig({ integrations: [ starlight({ customCss: ["./src/styles/custom.css"], }), ], markdown: { remarkPlugins: [remarkMath], rehypePlugins: [rehypeKatex], }, vite: { ssr: { noExternal: ["katex"], }, },});
Add CSS
@import url(katex/dist/katex.min.css);
When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$
When a≠0a \ne 0aî€ =0, there are two solutions to (ax2+bx+c=0)(ax^2 + bx + c = 0)(ax2+bx+c=0) and they are x=−b±b2−4ac2ax = {-b \pm \sqrt{b^2-4ac} \over 2a}x=2a−b±b2−4ac​​