[Tex/LaTex] Can’t generate png with Error: Erroneous nesting of equation structures

alignequationserrorsmath-mode

i am trying to generate pdf file from latex document with formula below

\documentclass[border=2pt]{standalone}
\usepackage{amsmath}
\usepackage{varwidth}
\begin{document}
\begin{varwidth}{\linewidth}
\begin{equation}
-\frac{\sqrt{2{{x}^{2}}-5x+2}}{3}\le x<0 \Leftrightarrow \left\{ \begin{align}
&   x<0  ,\\
&   -3x\le \sqrt{2{{x}^{2}}-5x+2}
\end{align} \right. \Leftrightarrow \left\{ \begin{align}
&   x<0  ,\\
&   9{{x}^{2}}\le 2{{x}^{2}}-5x+2
\end{align} \right. \Leftrightarrow \left\{ \begin{align}
&   x<0  ,\\
&   7{{x}^{2}}+5x-2\le 0
\end{align} \right. \Leftrightarrow
\end{equation}
\end{varwidth}
\end{document}

and got error message

! Package amsmath Error: Erroneous nesting of equation structures;
(amsmath) trying to recover with `aligned'.

See the amsmath package documentation for explanation.
Type H for immediate help.

l.10 \end{align}
\right. \Leftrightarrow \left{ \begin{align}

any other formulas work fine. Please help

Best Answer

Don't use align inside equation. Use aligned instead. Also there is no need for varwidth. The standalone class provides that option itself.

\documentclass[border=5pt,varwidth]{standalone}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
-\frac{\sqrt{2{{x}^{2}}-5x+2}}{3}\le x<0 \Leftrightarrow \left\{ \begin{aligned}
&   x<0  ,\\
&   -3x\le \sqrt{2{{x}^{2}}-5x+2}
\end{aligned} \right. \Leftrightarrow \left\{ \begin{aligned}
&   x<0  ,\\
&   9{{x}^{2}}\le 2{{x}^{2}}-5x+2
\end{aligned} \right. \Leftrightarrow \left\{ \begin{aligned}
&   x<0  ,\\
&   7{{x}^{2}}+5x-2\le 0
\end{aligned} \right. \Leftrightarrow
\end{equation*}
\end{document}

enter image description here