Alternatives and switching

KaTeX vs LaTeX

By imagetolatex team · Published

LaTeX is a complete typesetting system: it turns a .tex source file with text, math, references and figures into a PDF. KaTeX is a JavaScript library that only renders the math part of LaTeX syntax on web pages. They share the formula language — \frac{a}{b} means the same in both — but KaTeX cannot compile documents, load packages or number equations across a paper.

Side by side

LaTeXKaTeXMathJax
What it isTypesetting system (TeX engine + macros)JavaScript math rendererJavaScript math renderer
InputWhole .tex documentsFormulas onlyFormulas only
OutputPDFHTML on a web pageHTML, SVG or MathML
PackagesThousands (CTAN)None; a fixed set of commandsExtensions for many packages
SpeedCompiles the whole fileVery fast, renders synchronouslySlower, more complete
Typical usePapers, theses, books, slidesNotion, VS Code preview, fast sitesGitHub, Jupyter, Obsidian, MathOverflow

LaTeX that does not work in KaTeX

  • \usepackage and anything that needs a package KaTeX does not implement (TikZ, siunitx, chemistry packages).
  • Document structure: sections, lists, tables made with tabular, figures, \cite.
  • Equation numbering and cross-references with \label and \ref across a document.
  • Macros defined in one block are usually not available in another, depending on the app.

Most everyday math works the same: fractions, roots, sums, integrals, matrices, cases, aligned and the AMS symbols. When a formula fails in an app, test it in a full renderer first.

And MathJax?

MathJax is the other major web renderer. It supports more of LaTeX than KaTeX, reads extensions for many packages and has strong accessibility features (speech, MathML). KaTeX is faster and lighter. For a reader, the visible difference is small; for a site owner it is speed versus coverage.

Checking a formula before you paste it

The LaTeX equation editor renders with MathJax as you type and shows errors under the input, so you can fix a formula before pasting it into Notion, a website or Word.

The LaTeX equation editor with an aligned environment in the input and its rendered two-line preview
Test a formula in the editor before pasting it into a KaTeX app.

FAQ

Is KaTeX the same as LaTeX?
No. KaTeX renders the math part of LaTeX syntax on web pages; LaTeX typesets complete documents into PDF.
Can I use KaTeX to write a paper?
No. Use LaTeX (for example in Overleaf) for papers; KaTeX is for showing formulas on web pages and in apps.
Is KaTeX faster than MathJax?
Yes, KaTeX is built for speed and renders synchronously. MathJax supports more commands and accessibility features.
Which apps use KaTeX?
Notion and the VS Code Markdown preview use KaTeX; GitHub, Jupyter and Obsidian use MathJax.

Sources

Related guides

Converting more than one equation?

When the math is in a whole page, a PDF, a Word file or handwriting, these converters do it in one go and keep every equation editable.

Single printed formulas are free: 3 a day without an account, 6 with a free account. New accounts get 30 credits to try handwriting, pages and documents; failed conversions return their credits. See plans and credit prices.