LaTeX Equation Editor
Type LaTeX math on the left, or build it from the palette, and the formula is drawn on the right as you type. KaTeX 0.18.7 parses the source in your browser and writes MathML, and the browser's own MathML engine draws it with a math font already on your system. When the source cannot be read, the preview says what is wrong instead of drawing a stale formula; for a parse error it gives the line and column and marks the spot, Show in source selects it for you, and every character you typed stays where it was. Palette keys insert at the caret: with nothing selected a fraction arrives as \frac{a}{b} with the a selected, ready to type over, and with text selected the structure wraps it. Undo and Redo step back through every palette insert, example and clear, and through typing in steps that end at each space or line break you type. Copy the LaTeX or the MathML, download a PNG drawn with KaTeX's own fonts at twice the font size you set, on a transparent background, or download an SVG that holds the same MathML and, when that PNG can be made, a copy of it inside for programs that do not draw MathML. Links, images, HTML commands and macro definitions are turned off, so a pasted formula can only ever be math.
Loading the formula renderer.
- Status
- Loading
- SVG
- not drawn
- PNG
- not drawn
Loading the formula renderer.
Ctrl+Z or Command+Z undoes in the LaTeX pane, and Ctrl+Shift+Z, Command+Shift+Z or Ctrl+Y redoes. Display draws the formula in display style, with limits above and below a sum; Inline uses the compact text style, with limits beside the symbol and smaller fractions.
Palette
Each key inserts at the caret. With nothing selected, a structure arrives with its placeholder selected, ready to type over; with text selected, the structure wraps it and the caret moves past it.
Examples
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}e^{i\pi} + 1 = 0\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}\sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6}\det\begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bcf'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}
Common questions
- How do I write a fraction in LaTeX?
- Write \frac{numerator}{denominator}: \frac{a}{b} draws a over b with a bar between them. On this page the Fraction key in the palette inserts \frac{a}{b} at the caret with the a already selected, so the next thing you type replaces it. If you select some text first, say x+1, and then press the key, you get \frac{x+1}{b} instead. Fractions nest, so \frac{1}{1+\frac{1}{x}} is a continued fraction, and \dfrac or \tfrac force the display or text size when you need one inside the other.
- What happens when my LaTeX has a mistake?
- The preview is replaced by the reason and, when the parser reports one, its place in the source, and nothing you typed is changed. A missing closing brace in \frac{a}{b reads Line 1, column 11: Unexpected end of input in a macro argument, expected '}', with a note that a group is still open. An extra brace in \frac{a}{b}} is reported at column 12 as a } that closes nothing. The message shows that line with the spot marked, and Show in source selects it in the editor so you can fix it straight away. The preview comes back as soon as the source reads again, and Download SVG, Download PNG and Copy MathML stay off while it does not, so you cannot export a formula that is not the one on screen.
- Can I paste the equation into Word, Google Docs or a slide?
- Yes, in whichever form the program takes. Download PNG gives an image drawn with KaTeX's own fonts at twice the font size you set, with a transparent background, which documents, slides and chats accept as a picture; its letters can look a little different from the preview, which uses a math font from your system. Download SVG writes the formula as MathML inside the file, so a web browser draws it as sharp text at any size, and it carries that PNG as its fallback for programs that do not draw MathML inside SVG, when the PNG could be made; the status line says whether it was, and why not. Copy MathML puts the MathML markup on the clipboard, for pages and programs that accept MathML. Copy LaTeX gives you the source for Overleaf, a LaTeX document or a Markdown file with math.
- Which LaTeX commands work here?
- The math that KaTeX 0.18.7 supports: fractions, roots, sums, integrals and limits, subscripts and superscripts, Greek letters, accents, \left and \right delimiters, matrix, pmatrix, bmatrix, cases, aligned and gathered environments, \text, \color, and font commands such as \mathbb, \mathbf and \mathcal, which are drawn as the matching Unicode math letters, so \mathbb{R} becomes the character U+211D. A few things are turned off on purpose: \href, \url, \includegraphics and the HTML commands, which could reach outside the formula; \def, \newcommand and the other macro definitions; and \cancel, \sout and similar strike-outs, which not every browser's MathML engine draws. Download PNG refuses one more, \reflectbox, because it cannot draw the mirroring, and says so when you ask for one. A line break written as \\ on its own is not drawn as a new line by browsers' MathML engines, so put the lines in \begin{gathered} or \begin{aligned}. This is not a TeX installation: it lays out one formula and compiles no document.
- How big can a formula be?
- The source may be up to 20,000 bytes, groups may nest 40 levels deep, counting braces, \left and \right pairs and environments, and built-in shortcuts such as \iff and \Set may expand 30,000 times in one formula. Past any of these the page says which limit was reached and cuts nothing, so you can split the expression yourself. A PNG may be at most 8,192 pixels on a side and 16,777,216 pixels in all; at a large font size a long formula can pass that, and the page asks you to lower the size or take the SVG, which is written without the PNG copy inside and has no such limit.
- Why does my \mathbf or \mathbb look the same in every browser?
- Because the page writes the letters themselves rather than asking for a font. Browsers' MathML engines do not all honour a request for a bold or blackboard style, so a bold x can come out plain in one and bold in another. Instead, \mathbf{x} becomes the Unicode character mathematical bold small x, \mathbb{R} becomes double-struck R and \mathcal{L} becomes script L, and the same characters go into the preview, the MathML you copy and the SVG. Words in \textbf or \texttt keep their ordinary letters and are styled bold or monospace instead, so they still read as words when copied.
- Is my formula uploaded or stored?
- It is not uploaded: the renderer runs in your browser and nothing you type is sent anywhere. The draft, with its font size, colour and display setting, is kept in this browser alone once you change something, so it is there when you come back, and the Start over button above the heading forgets it. If the browser blocks storage the editor works the same and says the draft was not kept.
Supported math syntax only; no arbitrary TeX compilation, file access or remote macros.