3

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}

double_equal

2 Answers2

5

enter image description here

\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}
gernot
  • 49,614
  • 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
  • 2
    @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
  • What's the difference between alignedat{1} and an ordinary aligned with a single &? – Bernard Apr 18 '17 at 15:10
  • @Bernard Well, is there a difference? I haven't looked at the implementation, but probably not. – gernot Apr 18 '17 at 15:22
  • @gernot: I don't think there's one. It's just lighter to use aligned – Bernard Apr 18 '17 at 15:26
  • 1
    @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
  • @Bernard Thanks for the comment, I changed it. – gernot Apr 18 '17 at 15:28
  • 1
    @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
  • @gernot Let me consider that. The only hesitation is that in the entire project, the condition, such as, for some etc appears after the introduction, x=a_0y. Thx! – Athena Widget Apr 18 '17 at 16:29
4

enter image description here

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}

Addendum: considering Sigur coment:

enter image description here

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

\begin{document}
\[\setlength\arraycolsep{1pt}
\begin{array}{rlcl}
\text{Then } x  & = a_0y  &   &\text{for some } y \in D\\
                & = a_0uy & = &a_0yu\\
                &         & = &xu
\end{array}
\]
\end{document}
Zarko
  • 296,517