# [Tex/LaTex] Error – “Align used inside equation”, and unexpected 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.

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{split} a &= b + c \\ &= d + e \end{split}$$
\texttt{equation+aligned}
\begin{aligned} a &= b + c \\ &= d + e \end{aligned}
\texttt{equation+aligned[b]}
\begin{aligned}[b] a &= b + c \\ &= d + e \end{aligned}

\end{document}


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.)