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 Answers 2

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}
10
  • I see... a double alignment! Thx! Btw, can you briefly say what the {alignedat}[t]{1} does ? Apr 18, 2017 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, 2017 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;) Apr 18, 2017 at 14:57
  • 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, 2017 at 15:27
  • 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, 2017 at 15:34
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}
4
  • I was trying so hard to use this approach, but I could not get it to work. Thx! Apr 18, 2017 at 14:53
  • Since the space before for is not the default, I'd align it above a_0.
    – Sigur
    Apr 18, 2017 at 14:57
  • @Sigur Great suggestion! Done in reality. Apr 18, 2017 at 14:59
  • 2
    @AthenaWidget, as you see, array works and it is not so hard :)
    – Zarko
    Apr 18, 2017 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .