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:
pnpm add remark-math rehype-katex katexThen opt-in via docsShell():
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 .
\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.