LaTeX Errors and Warnings: Meanings and Fixes

Quick answer

  • Open the .log and find the first line starting with !. Fix that one first; later errors are often caused by it.
  • The l.42 line underneath gives the source line where TeX noticed the problem. The mistake is on that line or shortly before it.
  • Most errors come down to a misspelled command, a missing package, an unclosed { or $, or a \begin without its \end.

Every LaTeX error message below has its own page with the exact log line, the common causes, and a minimal broken document next to the corrected one. Every example was compiled to check that the broken version really produces the message and the fixed version compiles cleanly. Find your message in the list, or search this page for a word from it.

Commands, braces and arguments

Misspelled or missing commands, unbalanced braces and arguments that never end.

MessageWhat it means
Undefined control sequenceA command LaTeX does not know: misspelled, or its package is not loaded.
Missing } insertedA brace group was still open when math mode or a table cell ended.
Extra }, or forgotten $A } with no matching {, or a group that crosses a $ boundary.
Too many }'sA closing brace at the outer level of the document that closes nothing.
Runaway argumentA command argument that never ends: its closing brace is missing.
Paragraph ended before … was completeA blank line ended a command argument that may not contain paragraphs.
Command \x already defined\newcommand used a name that a package or LaTeX already defines.
Illegal parameter number in definitionA macro body uses #2 (or #) for an argument that the definition does not declare.

Math mode

Symbols outside math, unmatched delimiters and amsmath environments used in the wrong place.

MessageWhat it means
Missing $ insertedA math-only symbol (_, ^, \alpha) was used in text, or math mode was left early.
Missing \right. insertedA \left delimiter without its \right, often split across lines of align.
Double subscriptTwo _ (or two ^) in a row on the same base; group the inner one with braces.
Bad math environment delimiterAn opening \[ or \( used where a closing one belongs, or math mode opened twice.
\begin{split} won't work heresplit used outside a math display; wrap it in equation (or use align).

Environments, lists and tables

Unmatched \begin and \end, list items outside lists, and alignment problems in tables.

MessageWhat it means
Environment undefinedA \begin{...} name LaTeX does not know: usually a missing package or a typo.
\begin{x} ended by \end{y}An \end does not match the most recent open \begin: a typo or an environment left open.
Missing \begin{document}Something printable sits in the preamble, before \begin{document}.
Perhaps a missing \itemText inside a list before the first \item, or an empty bibliography or list.
Lonely \itemAn \item outside itemize, enumerate or description.
Misplaced alignment tab character &A literal & in normal text; write \&.
Extra alignment tabA table row has more & separators than the column specification allows.
There's no line here to endA \\ or \newline where no line of text has started.
Not in outer par modeA figure, table or \marginpar inside a box, minipage or table cell.
You can't use \hrule hereA TeX \hrule inside a table cell, box or math; use \hline or \rule.

Lengths and numbers

A length or number was expected and something else was found.

MessageWhat it means
Illegal unit of measureA length was given without a unit (or with an unknown one); write 2cm, 1em, 0.5\textwidth.
Missing number, treated as zeroTeX expected a number or length and found text, often a [ right after \\.
Dimension too largeA length went above TeX's maximum of 16383.99999pt (about 5.75 m); usually TikZ or pgfplots data.

Packages, files and fonts

Missing files, package option conflicts, encodings and fonts.

MessageWhat it means
I can't find fileA file read with \input (or the main file) does not exist under that name or path.
File not foundA package or class named in \usepackage or \documentclass is misspelled or not installed.
Option clash for packageA package is loaded twice with different options, often once by another package.
Package babel Error: Unknown optionThe language name given to babel is misspelled or its language file is not installed.
Unicode character not set up for use with LaTeXpdfLaTeX met a pasted Unicode symbol (≈, →, emoji, CJK) that it has no definition for.
Font shape undefined (warning)The current font has no such weight, shape or encoding, so LaTeX substitutes another one.
Token not allowed in a PDF string (warning)Math or a command in a section title cannot be copied into the PDF bookmarks.
Image file not found (pdftex.def)\includegraphics names an image file that does not exist at that path.

Warnings: references, floats and boxes

The PDF is produced, but citations, references, figures or lines are not what you expect.

MessageWhat it means
Citation undefined (warning)A \cite key has no matching bibliography entry yet, so the PDF shows [?].
Reference undefined (warning)A \ref or \eqref has no matching \label, so the PDF shows ??.
Overfull \hbox (warning)A line could not be broken and sticks out into the right margin.
Too many unprocessed floatsFigures or tables pile up behind one that LaTeX cannot place, until it runs out of float slots.

Fatal errors

Messages that stop the run entirely. The real cause is usually printed just above them.

MessageWhat it means
TeX capacity exceededTeX ran out of memory, almost always because of a command that calls itself.
Emergency stopThe run was aborted; the reason is in the line after it or in the error just above.

How to read a LaTeX error

A typical error in the log has three parts:

! Undefined control sequence.
l.12 The value is \alpah
                         = 0.5.
  • The message after ! says what TeX could not do.
  • The line number after l. says where in the source file it happened.
  • The line break in the context shows exactly how far TeX had read: the last token on the first line (\alpah here) is the one that failed.

Fix the first error and compile again before looking at the rest. The LaTeX tutorial for beginners covers the log in more detail, and commenting out blocks is the fastest way to find an error that the log does not pin down.

Frequently Asked Questions

How do I find the error in a LaTeX log?

Search the .log file for the first line that starts with an exclamation mark. That line is the error message, and the line below it that starts with l. gives the line number in your source where TeX noticed the problem. Fix that one first: later errors are often knock-on effects of the first.

What is the difference between a LaTeX error and a warning?

An error (a line starting with !) means TeX could not continue normally; the run stops or recovers with a guess, and the PDF may be missing or wrong. A warning (LaTeX Warning, Package ... Warning, Overfull or Underfull \hbox) still produces a PDF, but something such as a reference, a citation or a line break is not as intended.

Why does LaTeX report an error on the wrong line?

TeX reports the line where it noticed the problem, which can be well after the mistake. An unclosed brace or $ is only detected at the end of the paragraph or the document, and an error inside a macro is reported where the macro is used. Look at the l. line and the lines just before it.

Can I ignore LaTeX warnings?

Some, yes. Underfull and small Overfull \hbox warnings are cosmetic. Citation and reference warnings are not: they mean the PDF shows ?? or [?] in place of a number. Rerun LaTeX (and BibTeX or Biber) first; if a warning survives a full rerun, fix it.

How do I fix LaTeX errors automatically?

In Octree, every failed compile shows a Fix with AI button next to the error. It reads the log and your source, proposes the change, and you review it before it is applied. Each page in this list also explains the manual fix with a broken and a corrected example.

Paste your document into Octree — compile errors get a Fix with AI button

Octree compiles in the browser and shows each error next to the line that caused it, with a one-click fix you can review before applying.

Try Octree Free →