LaTeX math with KaTeX, pre-rendered at build time
Inline and display math, matrices, integrals, sums, Maxwell's equations and more — all rendered at build time, with the KaTeX stylesheet loaded only on opt-in pages.
The math is compiled statically at build time using @nullpinter/satteri-katex and
rendered to plain HTML + CSS.
Zero client JavaScript. Every equation below is server-rendered static markup. KaTeX runs only on the build server.
Add math: true to the post (or page) frontmatter:
---title: My math-heavy postmath: true---The theme component
MathStyles.astro is rendered only
when math: true, and Astro’s per-page CSS bundling guarantees that
katex.min.css (~29 kB) and its woff2 font assets are emitted only
on pages that include them. Non-math pages never download the
stylesheet.
Wrap inline expressions with single dollar signs: $ ... $.
The Pythagorean theorem states that for any right triangle with legs , and hypotenuse . Euler’s identity, , ties together five fundamental constants. The fine-structure constant is approximately .
To escape a literal dollar sign outside math, write \$, e.g. $5.00.
Use $$ ... $$ on their own lines for centred display equations.
The fundamental theorem of calculus:
Taylor series expansion:
A matrix and its determinant:
A linear system written compactly:
The Gaussian probability density function:
Bayes’ theorem:
Maxwell’s equations in SI units:
Schrödinger’s time-dependent equation:
- A blank line is required before and after a
$$block, otherwise Markdown can swallow the delimiters. - The same syntax works in both
.mdand.mdx. - Inside MDX, do not put
{immediately after$unless you intend a JSX expression — escape with\{if needed. - Forgot
math: true? You’ll see raw$x^2$text instead of a rendered formula. Add the flag and rebuild.
Pair this with the code blocks post — the two together cover everything you need to write technical content on this theme.
Comments
Comments need configuration
Giscus is enabled but not yet configured. Add the repository details below to start collecting comments.
- Visit
giscus.appand select your public GitHub repository (Discussions must be enabled). - Copy the generated
data-repo-id,data-categoryanddata-category-idvalues. - Set the
PUBLIC_GISCUS_ENABLED,PUBLIC_GISCUS_REPO,PUBLIC_GISCUS_REPO_ID,PUBLIC_GISCUS_CATEGORYandPUBLIC_GISCUS_CATEGORY_IDenv vars in your.envfile. - Rebuild the site — this notice will be replaced by the live comments thread.