LaTeX error "Erroneous nesting of equation structures": cause and fix
amsmath found a display environment such as align inside another display formula. align starts a display of its own and cannot stand inside equation or \[...\]. The package continues as if you had written aligned, so the PDF may look right, but the error stays.
Why it happens
alignstands insideequation, usually to get one number for several aligned lines.alignoralign*stands inside\[...\]or$$...$$.alignatorflalignstands insideequation. They report the same error.
How to fix it
- For one number for the whole block, keep
equationand replace the inner environment withalignedorsplit. - For a number on each line, remove the outer
equationand usealignalone. - For no numbers, use
align*alone, without\[...\]around it.
A document that produces the message
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{align}
a &= b + c \\
d &= e
\end{align}
\end{equation}
\end{document}The corrected document
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{aligned}
a &= b + c \\
d &= e
\end{aligned}
\end{equation}
\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
- How-to Align equations in LaTeX
- How-to Break a long equation over several lines in LaTeX
- Package
amsmath - Error Bad math environment delimiter