The errors we see most often after fixing hundreds of broken LaTeX projects - with exact fixes.
LaTeX error messages are famously unhelpful. The line number is wrong, the message describes a symptom not a cause, and the actual problem is three packages up in the preamble.
After fixing compilation errors across hundreds of academic papers and journal submissions at The LaTeX Lab, we've mapped which errors waste the most time and what actually fixes them. Here's the list.
1. ! Undefined control sequence
The most common error in LaTeX. It means you've used a command that LaTeX doesn't recognise.
The three actual causes:
Missing package. You used \textcolor{red}{text} but forgot \usepackage{xcolor}. The fix is always in the preamble - find the package that defines the command.
% Fix: add the right package
\usepackage{xcolor} % for \textcolor
\usepackage{amsmath} % for \text, \align, \DeclareMathOperator
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule
Typo in command name. \beginn{itemize} instead of \begin{itemize}. Check the exact spelling.
Command defined in a class file you're not loading. Common with journal templates - you copied a snippet from a paper that uses \IEEEauthorblockN{} but you're not using IEEEtran. Either load the right class or find the equivalent command in your class.
2. ! Missing $ inserted
LaTeX encountered a math symbol outside of math mode. Usually happens in one of three situations:
% Problem 1: Underscore in text
The variable x_1 is defined as... % ← _ triggers math mode error
% Fix:
The variable $x_1$ is defined as...
% Problem 2: Math command in text
The value is \alpha degrees. % ← \alpha only works in math mode
% Fix:
The value is $\alpha$ degrees.
% Problem 3: Underscore in a label or filename
\label{eq:result_final} % ← fine in labels, but check captions
\caption{Result\_comparison} % ← escape underscores in text contexts
The line number reported in this error is almost always wrong - LaTeX reports where it gave up, not where you made the mistake. Search backward from the reported line.
3. Package Conflicts (Option clash for package X)
This one is almost always caused by the same package being loaded twice with different options, either by you or by the class file.
! LaTeX Error: Option clash for package xcolor.
% The problem - you load it one way:
\usepackage[dvipsnames]{xcolor}
% The class file loads it another way internally:
\usepackage{xcolor} % no options
% Fix - load the package BEFORE the class, or use:
\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass{IEEEtran} % now the class inherits your options
The \PassOptionsToPackage command is the correct tool for resolving option clashes when you can't modify the class file.
4. ! File 'X.sty' not found
A package isn't installed in your TeX distribution.
On Overleaf: this almost never happens - Overleaf has a near-complete TeX Live installation. If you see it on Overleaf, the package name is probably misspelled.
On a local install: the package needs to be installed via your TeX package manager.
# TeX Live (Linux/Mac):
tlmgr install packagename
# MiKTeX (Windows):
# Use the MiKTeX Package Manager GUI, or:
mpm --install=packagename
If tlmgr says the package doesn't exist, check CTAN - the package may have been renamed or merged into another package.
5. Runaway argument / Paragraph ended before \X was complete
This usually means an unmatched brace or a blank line inside a command that doesn't allow it.
% Common cause 1: Missing closing brace
\textbf{Some important text % ← no closing }
% Common cause 2: Blank line inside \footnote or \caption
\caption{This is a table showing
the results. % ← blank line here breaks the argument
% Fix:
\caption{This is a table showing the results.}
Use your editor's brace-matching feature to find the unmatched brace. In Overleaf, the bracket highlighting will show you where the match is missing.
6. BibTeX Errors That Don't Show Up Until You've Fixed Everything Else
BibTeX errors are separate from LaTeX compilation errors and show up in the .blg log file, not the main log. Common ones:
Warning--missing journal in Jones2021
Warning--empty author in Smith2022
I was expecting a `,' or a `}'
The first two are missing required fields - BibTeX will still compile but the bibliography entry will be malformed. Fix them in your .bib file.
The third means a syntax error in your .bib file - usually a missing comma between fields or an unescaped special character:
% Problem: unescaped & in journal name
journal = {Transactions on Systems & Control}
% Fix:
journal = {Transactions on Systems \& Control}
Always check the .blg file after a full compile. LaTeX can report zero errors while your bibliography is silently malformed.
7. Overfull \hbox Warnings (The One You Should Actually Fix)
Overfull \hbox is a warning, not an error - LaTeX tells you text is sticking out into the margin. Most people ignore these. You shouldn't, because journals check for them.
% Common cause: a URL or long word that can't break
\url{https://verylongdomainname.com/with/a/very/long/path/to/something}
% Fix 1: allow URL line breaks
\usepackage{url} % or hyperref, which includes url
% Fix 2: for a long word, add a discretionary hyphen:
super\-cali\-fragi\-listic % LaTeX can break at these points
% Fix 3: use \sloppy locally for a paragraph that won't cooperate:
{\sloppy This paragraph has a very long URL that LaTeX can't break nicely. \par}
The Fastest Debug Workflow
When you have multiple errors, don't try to fix them all at once. LaTeX errors cascade - one missing brace causes 40 downstream errors. The workflow:
- Fix only the first error in the log
- Recompile
- Repeat
Also: comment out everything except the preamble and one paragraph, confirm it compiles, then add content back in sections. Binary search is faster than reading 200 error lines.
Further Reading
- Full guide to LaTeX compilation errors
- Word to LaTeX conversion - why automated tools fail
- How to format a paper for IEEE in LaTeX
If you're past the point of debugging and have a deadline tomorrow, The LaTeX Lab offers emergency LaTeX error fixing - 24–48 hour turnaround, with a plain-English explanation of what went wrong. Get a quote here.
Top comments (0)