sphinxcontrib-katex
A Sphinx extension for rendering math in HTML pages
What it is and what it does
sphinxcontrib-katex is a Sphinx extension that replaces the built-in MathJax renderer with KaTeX for displaying mathematical equations in HTML documentation. It processes LaTeX math delimiters in your documentation source and renders them using KaTeX's faster, lighter-weight engine. The extension supports custom LaTeX macros, configurable math delimiters, and optional server-side pre-rendering to shift rendering work from user browsers to your documentation build process.
The package integrates directly into Sphinx's build pipeline via its conf.py configuration file. It handles both inline and display math modes, allows fine-grained control over rendering options through katex_options, and can synchronize LaTeX macros across HTML and PDF builders. Optional nodejs-based pre-rendering trades build time for faster page loads in browsers.
Use it for:
- Replace MathJax with faster KaTeX rendering in scientific or technical Sphinx documentation projects.
- Pre-render mathematical equations on your documentation server to reduce browser load and improve page load speed.
- Define custom LaTeX macros once and use them consistently across both HTML and PDF documentation builds.
- Configure math delimiters and KaTeX rendering options to match your documentation's mathematical notation style.
- Migrate existing Sphinx documentation from the built-in mathjax extension to KaTeX with minimal configuration changes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Sphinx extension that renders mathematical equations in HTML documentation using KaTeX instead of MathJax, with optional server-side pre-rendering support.
Yes, if you maintain Sphinx documentation with mathematical content and want faster rendering than MathJax. The extension is stable, permissively licensed, and has low install friction. However, note that the package is aging (413 days since last release) and optional server-side pre-rendering adds a nodejs dependency; verify compatibility with your Sphinx version before committing to it in a large project.
Install
sphinxcontrib-katex on PyPI
pip
pip install sphinxcontrib-katexuv
uv add sphinxcontrib-katexpoetry
poetry add sphinxcontrib-katexInstalling sphinxcontrib-katex
Before you install
Low install friction with a single runtime dependency on sphinx. The package is in production/stable status and maintained actively, with a recent commit in June 2025. However, it is aging relative to its release cadence, and optional server-side pre-rendering requires a separate nodejs installation.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open and closed projects.
Quickstart
pip install sphinxcontrib-katex
# In conf.py of your Sphinx project:
extensions = ['sphinxcontrib.katex']
# Optional: enable server-side pre-rendering
katex_prerender = True
Server-side pre-rendering requires nodejs and a katex executable installed and in your PATH; browser-only rendering has no additional system dependencies.
Verify before relying
- Whether the package's aging maintenance status (413 days since last release) affects compatibility with recent Sphinx versions.
- Performance characteristics of server-side pre-rendering compared to browser-side rendering for large documentation sets.
- Completeness of KaTeX feature coverage relative to MathJax for complex mathematical notation.
Package facts
| License | The MIT License Copyright (c) 2017-2024 sphinxcontrib-katex Development Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — sphinx |
| Maintenance | aging — 413 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 129,229/month — #11,678 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sphinxcontrib_katex-0.9.11-py3-none-any.whl
Keywords: sphinx, latex, katex, math, documentation
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
python-markdown-mathAdds support for rendering mathematical…
permissive · top 15,000 on PyPI
sphinxcontrib-jsmathA Sphinx extension that renders mathematical…
permissive · top 1,000 on PyPI
sphinx-math-dollarA Sphinx extension that lets you write LaTeX…
permissive · top 15,000 on PyPI
sphinx-jupyterbook-latexA Sphinx extension that adds LaTeX output…
permissive · top 15,000 on PyPI
sphinxcontrib-htmlhelpA Sphinx extension that generates HTML help…
permissive · top 1,000 on PyPI
py-asciimathConverts between ASCIIMath, LaTeX, and MathML…
permissive · top 5,000 on PyPI
sphinx-markdown-tablesAdds markdown table support to Sphinx…
copyleft · top 15,000 on PyPI
simple-equA library of ready-to-use STEM equations…
permissive · top 15,000 on PyPI
latex2sympy2-extendedParses LaTeX math expressions and converts them…
permissive · top 5,000 on PyPI
sphinxcontrib-serializinghtmlA Sphinx extension that outputs documentation…
permissive · top 1,000 on PyPI