KaTeX online
A KaTeX online editor that renders LaTeX math as you type and exports the result as a PNG or as Unicode text, with no compile at all.
Open in LaTeX.to Download the example (zip)
- Recommended Active, 2014
- Engine dropdown: KaTeX (image)
- License: Public domain, use freely.
- Files:
main.tex
This is an example project with formulas KaTeX can render as you type. Euler's identity: $e^{i\pi} + 1 = 0$ The quadratic formula: $$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$ Glucose: $\ce{C6H12O6}$
How to use KaTeX on LaTeX.to
Nothing to install and no login: the editor is the whole tool.
- Click Open in LaTeX.to. The example opens with KaTeX selected in the engine dropdown and the formulas rendered in the preview.
- Type. Anything between
$...$,$...$,\(...\)or\[...\]is typeset as you pause; the text around it stays text. - The image menu above the preview has Save image (a transparent PNG), Copy image and Unicode, for a slide, a chat or an email.
What KaTeX is
KaTeX is a JavaScript library that typesets LaTeX math in a web page. Khan Academy wrote it to render thousands of formulas per page without the browser stalling, by implementing TeX's math layout in JavaScript with no server round trip. It renders the equations on many of the math sites you use.
It is not a TeX engine. It knows math mode and nothing else: no \documentclass, no \section, no packages, no PDF. On LaTeX.to it is one entry in the engine dropdown, and picking it turns the preview into a live renderer for whatever you type:
- Text stays text.
- Anything between
$...$,$$...$$,\(...\)or\[...\]becomes typeset math the moment you pause. - Chemical formulas work through the mhchem extension, as in the example's glucose line.
When to use it
- A formula for a slide, a chat, a Notion page or an email: the image menu above the preview saves a transparent PNG, copies it, or gives you the formula as Unicode text (
x^2 + \alphabecomes x² + α). - Checking a formula quickly while writing something else.
- Not for a whole document, a table, a figure, TikZ, or anything that needs a package. Switch the dropdown to Auto, wrap the formulas in a
\documentclass{article}withamsmath, and a real engine compiles it in the same browser.
KaTeX vs MathJax vs LaTeX
- MathJax: knows more commands and can render whole documents; KaTeX is much faster, renders synchronously so the page never jumps, and prints the same in every browser, which is why a preview that updates on every keystroke uses it.
- LaTeX: KaTeX is a subset of its math.
amsmathenvironments such asaligned,casesandmatrixwork,\text,\operatornameand\colorwork, but anything from a package is out (\bmbecomes\boldsymbol,\SIhas no equivalent). The supported-functions table on katex.org answers almost every "why does this not work".
Common errors
Undefined control sequence: a command KaTeX lacks. Look it up in the table; there is usually an alternative.No such environment: figure(ortable,enumerate): KaTeX renders math only. That belongs in a compiled document.Expected 'EOF', got '&': an&outside an alignment environment. Wrap the lines inalignedoralign.Can't use function '$' in math mode: a$inside a formula, usually delimiters that do not pair up.
The error shows in the preview as text at the formula that caused it, and the rest keeps rendering.
More engines: all engines.