Skip to main content
A LaTeX error names the problem and gives the line number after l., with the source line split where TeX stopped reading. Fix the first error in the log, compile again, and repeat: later errors are often side effects of the first one.

How to read an error message

This is what TeX Live 2026 writes to the log when an underscore appears in ordinary text:
main.log
Below the excerpt TeX prints a few lines of help text, such as “I’ve inserted a begin-math/end-math symbol since I think you left one out.” To read a whole log at once, paste it into the LaTeX error explainer. It finds the first real error, names the line and, for common errors, explains the fix.

Quick reference

Missing $ inserted

_ (subscript), ^ (superscript) and math commands such as \alpha, \sum or \frac only work in math mode. TeX inserts a $ to recover, so a second Missing $ inserted often follows in the same paragraph. A blank line inside \[ ... \] causes the same error, because a paragraph cannot end inside math.
underscore-error.tex
Escape the underscore in file names and identifiers, and put real math in $...$:
underscore-fixed.tex
Test this example live in your browser. Open a ready-to-compile LaTeX project with TeX Live 2026 preinstalled and zero local setup.Open starter article

Undefined control sequence

TeX does not know the command at the end of the first l. line. Check its spelling first. If the spelling is right, the package that defines it is not loaded:
main.log
toprule-error.tex
toprule-fixed.tex
Among the standard classes, \chapter exists in book and report, so it is undefined in article. A command defined with \newcommand must be defined before its first use.

Missing \begin{document}

main.log
LaTeX found text to print before \begin{document}. The preamble may contain only settings: \documentclass, \usepackage, \title and similar commands. The l. line shows the first character of the stray text; move that text into the document body.

Runaway argument and Paragraph ended before

main.log
Commands such as \textbf, \emph and \section do not accept a blank line inside their {...} argument, so close the brace before starting a new paragraph. When the brace is closed after a blank line, the message often names an internal command: \text@command for \textbf and \emph, \@sect for \section. If the closing } is missing altogether, TeX scans to the end of the file and reports File ended while scanning use of \textbf . (or \@xdblarg for \section) instead.

There’s no line here to end

main.log
\\ ends a line, so it fails where no line has started yet: at the start of a paragraph, or right after a blank line. To separate paragraphs, leave a blank line; to add vertical space, use \vspace{1em}. Paragraphs and new lines explains when \\ is the right tool.

Not in outer par mode

main.log
A figure or table environment is inside a box such as a minipage or \parbox, or inside another float. Floats must sit in the main text. To caption content inside a minipage, load the caption package and use \captionof{figure}{...} without the figure environment. Placement questions are covered on float and placement issues.

Environment … undefined

main.log
The environment name is misspelled, or the package that defines it is not loaded. comment comes from the comment package; align and gather come from amsmath (without it, the message is Environment align undefined.).

Missing \endcsname inserted

main.log
LaTeX turns label and citation keys into internal command names, and a command inside such a name is not allowed. Here \alpha in \ref{sec:\alpha} causes it. A command in \label{...} fails when LaTeX reads the .aux file back in at \end{document} (and at the start of the next compile), with the error reported in the .aux file (./main.aux:3:); after fixing the label, delete the .aux file. Use letters, digits and punctuation such as : or - in \label, \ref and \cite keys: \label{sec:alpha}.

Misplaced alignment tab character &

main.log
& separates columns in tables and align. In normal text, write \&.
ampersand-error.tex

Brace and environment mismatches

  • Too many }'s. means there is one } more than { on the reported line.
  • \begin{itemize} on input line 3 ended by \end{enumerate}. means an environment was closed with the wrong name. Match each \end{...} to its \begin{...}.

Content after \end{document}

LaTeX ignores everything after \end{document}. In TeX Live 2026 this produces no error or warning: the text is missing from the PDF. Move it above \end{document}.

Bold small caps do not appear

\textsc inside \textbf with the default fonts prints bold upright letters, and the log warns:
main.log
Load \usepackage[T1]{fontenc}: its fonts include bold small caps.

The fixes together

This document compiles without errors or warnings. It uses \&, T1 fonts for bold small caps, the comment package and \captionof inside a minipage:
fixed-errors.tex

When the message does not help

  1. Fix only the first error, then compile again.
  2. Halve the document. Move \end{document} to the middle of the body. If the error disappears, it is in the part you cut off; repeat on that half.
  3. Build a minimal example: \documentclass{article}, only the packages involved, and the few lines that fail.
  4. Delete auxiliary files (.aux, .toc, .out) after a failed run that left them incomplete, then compile again.

Errors with their own guides

Try the fixes

Start from the Basic Article template in LaTeX Cloud Studio, paste the failing lines into main.tex and compile them with the TeX Live 2026 installation the editor uses.