# Multiple = alignment

I'm trying to align the = of the third line with the second = of the second line. I've tried several combinations with no pleasing result. There are numerous 'alignment' questions and answers but none seem to fit this (trivial?) situation.

MWE:

\documentclass[12pt,a4paper]{article}

\usepackage[fleqn]{amsmath}

\begin{document}

\begin{alignat*}{2}
\text{Then } x &= a_0y \text{ for some } y \in D\\
&= a_0uy = a_0yu\\
&= xu
\end{alignat*}

\end{document}


\documentclass[12pt,a4paper]{article}

\usepackage[fleqn]{amsmath}

\begin{document}

\begin{alignat*}{2}
\text{Then } x &= a_0y \text{ for some } y \in D\\
&= a_0uy \begin{aligned}[t]
& = a_0yu\\
& = xu
\end{aligned}
\end{alignat*}

\end{document}

• I see... a double alignment! Thx! Btw, can you briefly say what the {alignedat}[t]{1} does ? – Athena Widget Apr 18 '17 at 14:50
• @AthenaWidget alignedat does the same as alignat, except that it is not a display environment but creates a table like tabular and array, which can be used anywhere in math mode. The [t] option does the same as for tabular and array: It aligns alignedat with its first line (top). – gernot Apr 18 '17 at 14:53
• Great!! Would you say this is then effectively the same as the array approach suggested by Zarko? i.e the {alignedat}[t]{1} does the table creation for us? (Sorry I'm still a bit green;) – Athena Widget Apr 18 '17 at 14:57
• @AthenaWidget The difference between array and alignedat/aligned is the spacing of the columns and rows. If you write x&=ay or x&=&ay in an array environment, it will be spaced unevenly or too wide; with extra tweaking you can use it as well. – gernot Apr 18 '17 at 15:27
• @AthenaWidget Anyway, even though you now have two or three solutions to choose from, I'm not sure that this is the best way of structuring the equation. I'd choose something more linear, using one or at most two lines. E.g. inline: Then, for some $y\in D$, we have $x=a_0y=...=xu$. Or: Since $x=a_0y$ for some $y\in D$, we have $x=...$. The best choice depends on where the argument is heading. – gernot Apr 18 '17 at 15:34

with array (simple and effective):

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}

\begin{document}
$\setlength\arraycolsep{1pt} \begin{array}{rll} \text{Then } x & = a_0y & \text{for some } y \in D\\ & = a_0uy & = a_0yu\\ & & = xu \end{array}$
\end{document}


\documentclass[12pt,a4paper]{article}
$\setlength\arraycolsep{1pt} \begin{array}{rlcl} \text{Then } x & = a_0y & &\text{for some } y \in D\\ & = a_0uy & = &a_0yu\\ & & = &xu \end{array}$

• Since the space before for is not the default, I'd align it above a_0`. – Sigur Apr 18 '17 at 14:57