[Tex/LaTex] Error – “Align used inside equation”, and unexpected \end{equation} after \begin{document}

equations

I have an error in my overleaf document but it is still compilable. I am not sure why im getting the error because I simply use the align function inside the equation function.

tion and

Best Answer

The environments align, alignat, flalign (and the corresponding starred variants) are top-level math environments and cannot be nested in other displayed equations (with a notable exception: you can use align & Co. within gather). Therefore you should either remove the "external" equation environment or use the "internal" form aligned, or split:

\documentclass{article}

\usepackage{amsmath}
\textwidth=5cm % just for the MWE

\begin{document}

\noindent\texttt{align}
\begin{align}
a &= b + c \\
  &= d + e
\end{align}
\texttt{align+nonumber}
\begin{align}
a &= b + c \nonumber \\
  &= d + e
\end{align}
\texttt{equation+split}
\begin{equation}
\begin{split}
a &= b + c \\
  &= d + e
\end{split}
\end{equation}
\texttt{equation+aligned}
\begin{equation}
\begin{aligned}
a &= b + c \\
  &= d + e
\end{aligned}
\end{equation}
\texttt{equation+aligned[b]}
\begin{equation}
\begin{aligned}[b]
a &= b + c \\
  &= d + e
\end{aligned}
\end{equation}

\end{document}

enter image description here

Equations (4) and (5) look the same, but the solution with aligned supports more alignment points. The cases (3) and (6) give the same output here but will in general differ in the vertical spacing between the formula and the surrounding text, since align never uses \abovedisplayshortskip. (For this reason I generally prefer aligned with the b option, though that might be debatable.)

Related Question