Skip to main content
Don’t panic! LaTeX errors can look scary, but most are easy to fix once you understand them. This guide covers the most common errors with clear solutions.
Quick tip: LaTeX error messages show the line number where the error occurred. Look for l.123 in the error message to find line 123 in your document.

Understanding LaTeX Error Messages

LaTeX errors follow this pattern:
Key parts:
  • ! indicates an error (not a warning)
  • Error description tells you what went wrong
  • l.123 shows the line number
  • The line content helps locate the issue

Most Common Errors

1. Missing $ inserted

Error message:
Cause: Math symbols used outside math mode Solutions:
wrong.tex
correct.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio
Common math symbols that need math mode: _, ^, \alpha, \sum, etc.

Finding the character in the log

TeX Live 2026 with -file-line-error prints the file and line first:
main.log
The l.3 line breaks where TeX stopped reading. The character just before the break, _ here, is the one that needs math mode. TeX inserts a $ to recover, so a second Missing $ inserted often follows later in the same paragraph, where TeX closes the math it opened. Fix the first one and recompile.

Other causes

  • _ or ^ in ordinary text, such as file names, variable names, and identifiers. Escape the character as \_, or put the name in \texttt{data\_2026.csv}. For web addresses, use \url from the url or hyperref package.
  • Math-only commands in text, such as \alpha, \geq, \frac, or \sum. Wrap them in $...$.
  • A blank line inside display math. A blank line inside \[ ... \] ends the paragraph while math is still open, and TeX reports Missing $ inserted on the blank line. Delete the blank line, or put % on it.
underscore.tex
underscore-fixed.tex
In LaTeX Cloud Studio, the Problems panel lists this error as Math mode character found outside math mode.

2. Undefined control sequence

Error message:
Cause: Using a command that doesn’t exist or missing package Solutions:
solution1.tex
solution2.tex

Finding the undefined command in the log

The undefined command is the last one on the first l. line, just before the line break:
main.log
Here it is \textbold. TeX’s own help text says the same: “The control sequence at the end of the top line of your error message was never \def’ed.”

Commands that need a package

If the command is spelled correctly, the package that defines it is probably not loaded: Two other causes are common. \chapter only exists in the book and report classes, so it is undefined in article. A command made with \newcommand must be defined before its first use, usually in the preamble of the main file.
toprule.tex
toprule-fixed.tex
In LaTeX Cloud Studio, the Problems panel lists this error as Undefined command in: followed by the line that contains it.

3. Missing \begin

Error message:
Cause: Content before \begin{document} or missing the command entirely Solution:
wrong.tex
correct.tex

4. File not found

Error message:
Cause: Missing package, image, or bibliography file Solutions:
  1. Install missing package:
  2. Check file paths:
  3. Use correct file extensions:

5. Missing } inserted

Error message:
Cause: Unmatched braces Solution:
wrong.tex
correct.tex
Use a text editor with brace matching to catch these errors early.

6. Environment undefined

Error message:
Cause: Using an environment that doesn’t exist or missing package Solution:
example.tex

7. Runaway argument

Error message:
Cause: Missing closing brace or bracket spanning paragraphs Solution:
wrong.tex
correct.tex

8. Overfull/Underfull hbox

Warning message:
Cause: Text doesn’t fit properly in the line Solutions:
  1. Let LaTeX hyphenate:
  2. Force hyphenation:
  3. Rewrite the sentence
  4. Allow stretchy spacing:

9. Table/Figure positioning problems

Issue: Tables or figures appear in wrong locations Solutions:
positioning.tex

10. Bibliography not showing

Issue: References not appearing Solution sequence:

Error Categories

Math Mode Errors

Common math mode mistakes:
  • Text in math: Use \text{...} from amsmath
  • Wrong delimiter size: Use \left( and \right)
  • Display math in wrong place: Can’t use $$ in some environments
math-fixes.tex

Package Conflicts

Some packages don’t work well together:
example.tex

Font Errors

example.tex

Debugging Strategies

1. Binary Search Method

Comment out half your document to isolate errors:
example.tex

2. Minimal Working Example (MWE)

Create a minimal file that reproduces the error:
example.tex

3. Check the Log File

Look for:
  • First error (fix this first)
  • Line numbers
  • Package warnings
  • Overfull/underfull boxes

4. Common Quick Fixes

Clear auxiliary files

Delete .aux, .log, .toc files and recompile

Update packages

Keep your TeX distribution updated

Check encoding

Save files as UTF-8

Simplify first

Remove packages/commands until it works

Prevention Tips

Best practices to avoid errors:
  1. Compile frequently (after every few lines when learning)
  2. Use a good editor with syntax highlighting
  3. Keep backups before major changes
  4. Organize long documents into multiple files
  5. Comment your code for complex parts
  6. Use version control (Git)

Platform-Specific Issues

Windows

  • Path issues: Use forward slashes / or double backslashes \\
  • Font issues: Install fonts system-wide
  • Encoding: Save as UTF-8, not ANSI

macOS

  • Missing fonts: Install MacTeX fully
  • Path issues: Don’t use spaces in filenames
  • Preview issues: Use external PDF viewer

Linux

  • Permission issues: Check file permissions
  • Missing packages: Use distribution package manager
  • Font issues: Update font cache

Getting Help

When asking for help online, include:
  1. Minimal Working Example (MWE)
  2. Complete error message
  3. TeX distribution and version
  4. What you’ve already tried

Help Resources

Quick Reference Card


Remember: Every LaTeX user encounters errors. They’re not a sign of failure but an opportunity to learn. The more errors you fix, the better you become at LaTeX!
Still stuck? Create a Minimal Working Example (MWE) - a small, self-contained document that reproduces your error - and ask for help in the community forums. Happy TeXing!

You’ve Completed the Basics!

Congratulations on finishing the LaTeX basics! Here’s where to go next: