Skip to content

Math support in Markdown

aka: LaTeX, KaTeX, MathJAX

Installation

  1. Install dependencies

    Terminal window
    pnpm add starlight-katex
  2. Configure Astro

    astro.config.mjs
    import { starlightKatex } from "starlight-katex";
    export default defineConfig({
    integrations: [
    starlight({
    plugins: [starlightKatex()],
    }),
    ],
    });

Example

example.md
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 a0a \ne 0, there are two solutions to (ax2+bx+c=0)(ax^2 + bx + c = 0) and they are

x=b±b24ac2ax = {-b \pm \sqrt{b^2-4ac} \over 2a}