skillfed

sphinxcontrib-katex

A Sphinx extension for rendering math in HTML pages

sphinxcontrib-katex v0.9.11 129.2K downloads/30d#11,678 on PyPI30
Permissive 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) AGING released

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-katex

uv

uv add sphinxcontrib-katex

poetry

poetry add sphinxcontrib-katex

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: DocumentationTopic :: Scientific/EngineeringTopic :: Utilities

Tags

sphinx math renderingkatex sphinx extensionhtml equation renderingsphinx documentation mathlatex math in sphinxserver-side math prerenderingsphinx math html
math-renderingsphinx-extensiondocumentation-tools

More Scientific/Engineering packages