All documentation

Fixing compilation errors

When a document does not compile, the status reads LaTeX error and the PDF tab shows what LaTeX reported. The last PDF that compiled stays on screen, and nothing you wrote is lost.

Where errors come from

Text is never interpreted as LaTeX, so a paragraph, a caption or a table cannot break a compilation by its content. Almost every error comes from a formula — an equation block or a formula inside a sentence — because that is where you write LaTeX yourself.

The editor's preview and LaTeX read the same formula, but the preview is a little more forgiving: it tolerates some mistakes, and it draws a few commands that cannot be printed — the editor warns you about those under the formula. A formula can look right in the editor and still be refused.

Finding the formula

  1. Open the PDF Preview tab. The banner shows the first error and a line number, for example "Line 42: Undefined control sequence".
  2. Open the LaTeX tab and go to that line. The line numbers on the left are the ones the error uses.
  3. Read the lines around it: you will recognise the formula. Go back to the Editor tab and correct it.

Show full compiler output in the banner displays everything LaTeX printed, including the command it stopped on.

LaTeX stops at the first error. Fix it and compile again: there may be another one further down.

Common errors

Undefined control sequence

LaTeX does not know a command.

  • A typo: \frc for \frac, \aplha for \alpha.
  • A command the preview draws and LaTeX cannot print. The editor names it under the formula: "\phase is drawn here, but LaTeX does not know it". Replace it with a standard command. The usual shorthands and extras are not in this case — \R, \bm, \cancel, \mathscr, \coloneqq, \textcolor all compile: see Equation.
  • A command from a package that is not available: \SI, \qty, \dv, \tikz… See the list of what is available in Equation.
  • A set that is not a shorthand: \Q and \C do not exist. Write \mathbb{Q}, \mathbb{C}.

Missing $ inserted

Something that only exists in maths was found in text, or the reverse.

  • An underscore or a caret inside \text{…}: write \text{max\_value}, or keep it out of \text.
  • A $ typed inside a formula. A formula never contains $: you are already in maths.

Misplaced alignment tab character &

An & in an environment that does not align. & is for align, for matrices and for cases. In the right column, change the equation's environment to align, or remove the &.

Extra alignment tab has been changed to \cr

A row has more & than the environment has columns — usually a matrix row with one & too many, or a matrix wider than 20 columns.

Missing } inserted · Extra } · Runaway argument

Braces do not match. Count them: every { needs its }. \frac takes two groups — \frac{a}{b} — and \sqrt one.

Missing \right. inserted · Extra \right

\left and \right go in pairs, on the same row. In an align, a pair cannot open on one row and close on the next: close it with \right. and reopen with \left..

\begin{…} ended by \end{…}

An environment was opened and not closed, or closed with the wrong name: \begin{pmatrix} needs \end{pmatrix}.

Double superscript · Double subscript

x^a^b is ambiguous. Write x^{a^b} or {x^a}^b.

Environment … undefined

An environment from a package that is not loaded. See the list of what is available in Equation.

There's no line here to end

In a formula, this means a \\ where there is nothing to break — at the start of an equation, for instance. \\ belongs in align, gather, multline and matrices.

Timed out

A compilation is stopped after 30 seconds. It is rare; compile again. If it keeps happening, the document is very large or a formula sends LaTeX into a loop — look at what you changed last.

Compile failed

The compiler could not be reached, or you have reached a limit: two documents compiling at once, or the hourly limit. The message says how long to wait. See Limits.

If you cannot find it

  • Recall what you changed since the last PDF that worked: the error is there.
  • Cut the content of a suspect formula, compile, and paste it back piece by piece.
  • An empty equation is never the problem: it prints nothing.

Things that cannot cause an error

So you do not look in the wrong place: special characters in text (%, &, _, #, $), a caption, a table cell, a title, an author's name, a bibliography entry, or the content of a code block. All of these are made safe before they reach LaTeX.