LaTeX Errors and Warnings: Meanings and Fixes
Quick answer
- Open the
.logand find the first line starting with!. Fix that one first; later errors are often caused by it. - The
l.42line 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\beginwithout 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.
| Message | What it means |
|---|---|
| Undefined control sequence | A command LaTeX does not know: misspelled, or its package is not loaded. |
| Missing } inserted | A 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 }'s | A closing brace at the outer level of the document that closes nothing. |
| Runaway argument | A command argument that never ends: its closing brace is missing. |
| Paragraph ended before … was complete | A 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 definition | A 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.
| Message | What it means |
|---|---|
| Missing $ inserted | A math-only symbol (_, ^, \alpha) was used in text, or math mode was left early. |
| Missing \right. inserted | A \left delimiter without its \right, often split across lines of align. |
| Double subscript | Two _ (or two ^) in a row on the same base; group the inner one with braces. |
| Bad math environment delimiter | An opening \[ or \( used where a closing one belongs, or math mode opened twice. |
| \begin{split} won't work here | split 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.
| Message | What it means |
|---|---|
| Environment undefined | A \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 \item | Text inside a list before the first \item, or an empty bibliography or list. |
| Lonely \item | An \item outside itemize, enumerate or description. |
| Misplaced alignment tab character & | A literal & in normal text; write \&. |
| Extra alignment tab | A table row has more & separators than the column specification allows. |
| There's no line here to end | A \\ or \newline where no line of text has started. |
| Not in outer par mode | A figure, table or \marginpar inside a box, minipage or table cell. |
| You can't use \hrule here | A 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.
| Message | What it means |
|---|---|
| Illegal unit of measure | A length was given without a unit (or with an unknown one); write 2cm, 1em, 0.5\textwidth. |
| Missing number, treated as zero | TeX expected a number or length and found text, often a [ right after \\. |
| Dimension too large | A 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.
| Message | What it means |
|---|---|
| I can't find file | A file read with \input (or the main file) does not exist under that name or path. |
| File not found | A package or class named in \usepackage or \documentclass is misspelled or not installed. |
| Option clash for package | A package is loaded twice with different options, often once by another package. |
| Package babel Error: Unknown option | The language name given to babel is misspelled or its language file is not installed. |
| Unicode character not set up for use with LaTeX | pdfLaTeX 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.
| Message | What 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 floats | Figures 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.
| Message | What it means |
|---|---|
| TeX capacity exceeded | TeX ran out of memory, almost always because of a command that calls itself. |
| Emergency stop | The 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 (
\alpahhere) 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 →