[Tex/LaTex] Aligning two different symbols (\iff symbol, and =) in an equation

amsmath

So this was my code:

\begin{align*}
\frac{\vert\overline{AD}\vert}{\vert\overline{CD}\vert}=&\frac{\vert\overline{DC}\vert}{\vert\overline{CE'}\vert}\\
\iff&& \frac{1}{x}=&\frac{x}{1-x}\\
\iff&& 1-x=&x^2\\
\iff&& 0=&x^2+x-1
\end{align*}

Everything worked as expected except the first line, which for some reason decided to hate me. Any ideas?

Best Answer

You forgot && for the first line.

I suggest alignat, though, in order to have less blank space between the arrows and the equations.

You should use &= and not =&.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
&\qquad&
  \frac{\lvert\overline{AD}\rvert}{\lvert\overline{CD}\rvert}
    &=\frac{\lvert\overline{DC}\rvert}{\lvert\overline{CE'}\rvert}\\
\iff&& \frac{1}{x}&=\frac{x}{1-x}\\
\iff&& 1-x&=x^2\\
\iff&& 0&=x^2+x-1
\end{alignat*}

\end{document}

enter image description here

On the other hand, I'd not align the = signs.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
&\quad
  \frac{\lvert\overline{AD}\rvert}{\lvert\overline{CD}\rvert}
    =\frac{\lvert\overline{DC}\rvert}{\lvert\overline{CE'}\rvert}\\
\iff&\quad \frac{1}{x}=\frac{x}{1-x}\\
\iff&\quad 1-x=x^2\\
\iff&\quad 0=x^2+x-1
\end{align*}

\end{document}

enter image description here

Related Question