LaTeX error "Erroneous nesting of equation structures": cause and fix

Error Erroneous nesting of equation structures

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

How to fix 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}

Open in the editor

The corrected document

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{aligned}
a &= b + c \\
d &= e
\end{aligned}
\end{equation}
\end{document}

Open in the editor

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