✨ Publier v1 is live — a polished docs platform built for the open web.
Skip to content

Math Equations

Render mathematical expressions using KaTeX — enabled via the Publier integration.

Math support renders LaTeX expressions via KaTeX. Enable it with one option in astro.config.ts.

Setup

Install the peer dependencies:

Terminal window
pnpm add remark-math rehype-katex katex

Then opt-in via docsShell():

astro.config.ts
import tailwind from '@tailwindcss/vite';
import { defineConfig } from 'astro/config';
import { docsShell } from '@publier/shell/integration';
export default defineConfig({
integrations: [docsShell({ math: true })],
vite: { plugins: [tailwind()] },
});

That’s it — Publier wires up the math pipeline and logs a warning if the peer dependencies are missing rather than crashing your build.

Usage

Inline math — wrap in single dollar signs:

The energy–mass equivalence is $E = mc^2$.

Block math — wrap in double dollar signs on their own lines:

$$
\int_0^\infty e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}
$$

Display result:

The energy–mass equivalence is E=mc2E = mc^2.

\int_0^\infty e^{-x^2} \, dx = \frac{\sqrt{\pi}}{2}

KaTeX reference

See the KaTeX supported functions for the full list of supported LaTeX commands.