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.

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

equations

## 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`

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