LaTeX error "Extra }, or forgotten $": cause and fix
Inside a formula TeX found a } that closes nothing. Either the brace is surplus, or the formula should have ended with $ before it. TeX deletes the brace and goes on.
Why it happens
- The formula has one
}too many:$\frac{a}{2}}$. - An opening brace is missing:
$\frac{a}2}$. - A formula inside the argument of a text command is not closed. In
\textbf{for $b>0}the second$is missing, so the}of\textbfarrives in math mode. - A cell of an
array, a matrix or acasesenvironment contains a surplus}.
How to fix it
- Count the braces of the formula in the line the log names and delete the surplus one.
- Close every inline formula with
$before the argument around it ends. - Write a brace that should be printed as
\{or\}.
A document that produces the message
\documentclass{article}
\begin{document}
The area is $\frac{a}{2}}$ in this case.
\end{document}The corrected document
\documentclass{article}
\begin{document}
The area is $\frac{a}{2}$ in this case.
\end{document}Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.
Finding the line in the editor
The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.
Related pages
- Error Too many }'s
- Error Missing $ inserted
- Error Missing } inserted
- How-to Fractions in LaTeX