Top 20 LaTeX Errors and How to Fix Them

  • JNext lesson
  • KPrevious lesson
  • FSearch lessons
  • EscClear search

Every error here has been made by every LaTeX user. The fix is usually one line.

1. Undefined control sequence

! Undefined control sequence.
l.15 \bgin{equation}

Cause: Typo in a command name. Here, \bgin should be \begin.

Fix: Check spelling. Check that the package providing the command is loaded.

2. Missing $ inserted

! Missing $ inserted.
l.22 x^2

Cause: Math syntax outside math mode.

Fix: Wrap in $...$ or <!--M0-->.

3. Missing } inserted / Extra }

! Missing } inserted.

Cause: Unmatched braces.

Fix: Count your braces. Every { needs a }. Use editor brace matching.

4. Environment ended by \end{wrong}

! LaTeX Error: \begin{equation} ended by \end{align}.

Cause: Mismatched \begin/\end environment names.

Fix: Make them match.

5. File not found

! LaTeX Error: File `fancyhdr.sty' not found.

Cause: Package not installed.

Fix: tlmgr install fancyhdr (TeX Live) or let MiKTeX auto-install.

6. Too many }’s

! Too many }'s.
l.30 \frac{a}{b}}

Cause: Extra closing brace.

Fix: Remove the extra }.

7. Misplaced alignment tab character &

Cause: Using & outside a tabular or alignment environment.

Fix: Use \& in text, or put & only inside tabular, align, etc.

8. Extra alignment tab has been changed to \cr

Cause: More & columns than the table specification allows.

Fix: Add a column to your specifier or remove the extra &.

9. Font not found (xelatex)

! fontspec error: "font-not-found"
! The font "STIX Two Text" cannot be found.

Cause: Font not installed on your system.

Fix: Install the font or change \setmainfont to an available font.

10. Overfull \hbox

Overfull \hbox (15.3pt too wide) in paragraph at lines 40--45

Cause: Content extends past the margin.

Fix: Rephrase text, use \sloppy, add hyphenation hints, or break long URLs with \url.

11. Underfull \hbox

Cause: A line has too much white space (badness > 1000).

Fix: Usually harmless. Rephrase if the gap is visually noticeable.

12. Reference undefined

Cause: Label doesn’t exist, or you only compiled once.

Fix: Compile twice. Check that \label{sec:foo} exists.

13. Citation undefined

Cause: BibTeX/Biber hasn’t been run, or the key is wrong.

Fix: Run bibtex/biber, then compile twice more.

14. Package hyperref Warning: Token not allowed

Cause: Math or special commands in section titles with bookmarks.

Fix: Use \texorpdfstring: \section{The \texorpdfstring{\LaTeX}{LaTeX} Book}.

15. Float too large for page

Cause: Figure/table is taller than the text area.

Fix: Reduce image size or use \includegraphics[height=0.8\textheight].

16. Option clash for package

! LaTeX Error: Option clash for package xcolor.

Cause: Package loaded twice with different options.

Fix: Load the package once (with all options), or use \PassOptionsToPackage before \documentclass.

17. Command already defined

Cause: \newcommand on a name that already exists.

Fix: Use \renewcommand if intentional, or choose a different name.

18. Dimension too large

Cause: A length exceeds TeX’s maximum (~5.75 meters).

Fix: Check for infinite loops in length calculations or very large scaling factors.

19. TeX capacity exceeded

Cause: Infinite recursion or extremely complex macros.

Fix: Check for recursive \newcommand definitions. Simplify.

20. Paragraph ended before command was complete

Cause: Blank line inside a command argument.

Fix: Remove the blank line or use % at the end of lines to prevent paragraph breaks.

Tip: When debugging, always fix the first error and recompile. Later errors are often cascading effects of the first one. Don’t try to fix all errors at once.