Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the following code, I have the appropriate alignment. All the equal signs are aligned. There is one expression that is written on two lines; I wanted the first plus signs aligned. I used an aligned[t] environment to get this. How do I get this using an alignat{2} environment?

\documentclass[draft,a4paper,landscape]{amsart}
\usepackage{}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{mathtools,array}

\begin{document}

\noindent $a = x_{1} + iy_{1}$ and $z = x_{2} + iy_{2}$.
\begin{align*}
\big\vert 1 - \overline{a}z \big\vert^{2} &= \big\vert 1 - x_{1}x_{2} - y_{1}y_{2} + i(x_{1}y_{2} - x_{2}y_{1}) \big\vert^{2} \\
&= \begin{aligned}[t]1 &+ {x_{1}}^{2}{x_{2}}^{2} + {y_{1}}^{2}{y_{2}}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} + 2x_{1}x_{2}y_{1}y_{2} \\
&+ {x_{1}}^{2}{y_{2}}^{2} + {x_{2}}^{2}{y_{1}}^{2} - 2x_{1}x_{2}y_{1}y_{2}
\end{aligned} \\
&= \begin{aligned}[t]1 + {x_{1}}^{2}{x_{2}}^{2} + {y_{1}}^{2}{y_{2}}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} + {x_{1}}^{2}{y_{2}}^{2} + {x_{2}}^{2}{y_{1}}^{2}
\end{aligned} \\
&= \begin{aligned}[t]1 + ({x_{1}}^{2} + {y_{1}}^{2}) ({x_{2}}^{2} + {y_{2}}^{2}) - 2x_{1}x_{2} - 2y_{1}y_{2} ,
\end{aligned}
\intertext{and}
\vert z - a \vert^{2} &= \mathmakebox[0pt][l]{\vert x_{2} - x_{1} + i(y_{2} - y_{1}) \vert^{2}} \\
&= {x_{1}}^{2} + {x_{2}}^{2} + {y_{1}}^{2} + {y_{2}}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} .
\end{align*}

\end{document}
share|improve this question

3 Answers 3

Here is one way to use the alignat environment:

enter image description here

Notes:

  • Replaced the \intertext with \shortintertext as I think that looks better when you have very small text as it adds less vertical space before and after the text.
  • Used \mathrlap to ensure that portions of some lines did not affect the alignment in the other lines.
  • Aligned as many of the binary operators as I thought made sense without reorganizing the terms of the equations, or that did not leave too much blank space. Adjust this as desired.
  • Since _each & provides a r and l alignment point, double && are used for all subsequent alignment points so that the text following the && is left aligned.

References:

Code:

\documentclass[draft,a4paper,landscape]{amsart}
\usepackage{}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{mathtools,array}


\begin{document}

\noindent $a = x_{1} + iy_{1}$ and $z = x_{2} + iy_{2}$.
\begin{alignat*}{7}
\big\vert 1 - \overline{a}z \big\vert^{2} 
&= \big\vert &&1 &&- x_{1}x_{2} - y_{1}y_{2} + \mathrlap{i(x_{1}y_{2} - x_{2}y_{1}) \big\vert^{2}} \\
&= && 1 &&+ {x_{1}}^{2}{x_{2}}^{2} + {y_{1}}^{2}{y_{2}}^{2} - 2x_{1}x_{2}  &&- 2y_{1}y_{2}  &&+ 2x_{1}x_{2}y_{1}y_{2} \\
& && &&+ {x_{1}}^{2}{y_{2}}^{2} + {x_{2}}^{2}{y_{1}}^{2}  && &&- 2x_{1}x_{2}y_{1}y_{2}  \\
&= && 1 &&+ {x_{1}}^{2}{x_{2}}^{2} + {y_{1}}^{2}{y_{2}}^{2} - 2x_{1}x_{2}  &&- 2y_{1}y_{2} &&+ {x_{1}}^{2}{y_{2}}^{2} + {x_{2}}^{2}{y_{1}}^{2} \\
&= && 1 &&+ ({x_{1}}^{2} + {y_{1}}^{2}) ({x_{2}}^{2} + {y_{2}}^{2}) &&- 2x_{1}x_{2} &&- 2y_{1}y_{2} ,
\shortintertext{and}% <--- Replaced \intertext
\vert z - a \vert^{2} &= \mathrlap{\vert x_{2} - x_{1} + i(y_{2} - y_{1}) \vert^{2}} \\
&= \mathrlap{{x_{1}}^{2} + {x_{2}}^{2} + {y_{1}}^{2} + {y_{2}}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2}} .
\end{alignat*}

\end{document}
share|improve this answer
    
I adapted your code to the alignments that I had. Thanks. How is "and" displayed differently using the \intertext and \shortintertext commands? How does "\mathrlap{}" in the first line of code keep the alignment? I compiled the code without it and the display had the "1" aligned but they were aligned about an inch from the equal signs. –  user60254 Aug 9 at 20:02
    
@user60254: Updated answer to attempt to answer your questions. If still not clear, might be useful to have a separate question. –  Peter Grill Aug 9 at 20:12

I think it would be much too complicated to use alignat. Actually you only need one aligned environment. Note the \! to have an exact (first) alignment.

I don't see the necessity of aligning the + signs of the second and third lines of the alignment. I prefer aligning differently, so as to show clearly the third line is the continuation of the second ; I also made a smaller vertical spacing between these lines, thus making, in my opinion, the equations more readable.

If you want to use alignat it will be more complex — it wil be alignat{3} and a number of \rlap commands:

\documentclass[draft,a4paper,landscape]{amsart}
\usepackage{}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{mathtools,array}

\begin{document}

\noindent $a = x_{1} + iy_{1}$ and $z = x_{2} + iy_{2}$.
\begin{align*}
\big\vert 1 - \overline{a}z \big\vert^{2} &= \big\vert 1 - x_{1}x_{2} - y_{1}y_{2} + i(x_{1}y_{2} - x_{2}y_{1}) \big\vert^{2} \\
&=\!\begin{aligned}[t]1 + x_{1}^{2}x_{2}^{2}+ y_{1}^{2}y_{2}^{2} &- 2x_{1}x_{2} - 2y_{1}y_{2} + 2x_{1}x_{2}y_{1}y_{2} \\[-0.5ex]
  & + x_{1}^{2}y_{2}^{2} + x_{2}^{2}y_{1}^{2} - 2x_{1}x_{2}y_{1}y_{2}
 \end{aligned}
 \\
&=1  + x_{1}^{2}x_{2}^{2} + y_{1}^{2}y_{2}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} + x_{1}^{2}y_{2}^{2} + x_{2}^{2}y_{1}^{2}
 \\
&= 1 + (x_{1}^{2} + y_{1}^{2}) (x_{2}^{2} + y_{2}^{2}) - 2x_{1}x_{2} - 2y_{1}y_{2} ,
\intertext{and}
\vert z - a \vert^{2} &= \mathmakebox[0pt][l]{\vert x_{2} - x_{1} + i(y_{2} - y_{1}) \vert^{2}} \\
&= x_{1}^{2} + x_{2}^{2} + y_{1}^{2} + y_{2}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} .
\end{align*}\vskip1cm

With an \texttt{alignat} environment,  it is much more complex: 
\begin{alignat*}{3}
\big\lvert 1 - \overline{a}z \big\rvert^{2} &= \mathrlap{\big\lvert 1   - x_{1}x_{2} - y_{1}y_{2}{}+ i(x_{1}y_{2} - x_{2}y_{1}) \big\rvert^{2}} \\
&= 1& &{}  + x_{1}^{2}x_{2}^{2}+ y_{1}^{2} y_{2}^{2}  &  &{} - 2x_{1}x_{2} - 2y_{1}y_{2} + 2x_{1}x_{2}y_{1}y_{2} \\[-0.5ex]
  & &  & &  &    + x_{1}^{2}y_{2}^{2} + x_{2}^{2}y_{1}^{2} - 2x_{1}x_{2}y_{1}y_{2}
 \\
&=1 &&{} + \mathrlap{x_{1}^{2}x_{2}^{2} + y_{1}^{2}y_{2}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} + x_{1}^{2}y_{2}^{2} + x_{2}^{2}y_{1}^{2}}
 \\
&=1& &{}+ \mathrlap{(x_{1}^{2} + y_{1}^{2}) (x_{2}^{2} + y_{2}^{2}) - 2x_{1}x_{2} - 2y_{1}y_{2} ,}
\intertext{and}
\vert z - a \vert^{2} &= \mathrlap{\vert x_{2} - x_{1} + i(y_{2} - y_{1}) \vert^{2}} \\
&=\mathrlap{ x_{1}^{2} + x_{2}^{2} + y_{1}^{2} + y_{2}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2}.}
\end{alignat*}

\end{document} 

enter image description here

share|improve this answer
    
I wanted to use the alignat environment to familiarize myself with it. As you saw from my code, I got the proper alignment using the aligned environment within the align environment. (I did forget to add the "\!" before the aligned environment.) Please give me your display using the alignat environment. –  user60254 Aug 9 at 18:53
    
I'll do that in a moment., but I must warn you it will be more complicated. –  Bernard Aug 9 at 19:04
    
@user60254: Iadded a solution with alignat{3} that I wouldn't advise… –  Bernard Aug 9 at 20:26

Here is a solution which doesn't used an environment:

\documentclass[draft,a4paper,landscape]{amsart}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{mathtools}

\begin{document}

\noindent $a = x_{1} + iy_{1}$ and $z = x_{2} + iy_{2}$.
\begin{align*}
\big\vert 1 - \overline{a}z \big\vert^{2} &= \big\vert 1 - x_{1}x_{2} - y_{1}y_{2} + i(x_{1}y_{2} - x_{2}y_{1}) \big\vert^{2} \\
&= 1 + {x_{1}}^{2}{x_{2}}^{2} + {y_{1}}^{2}{y_{2}}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} + 2x_{1}x_{2}y_{1}y_{2} \\
&\phantom{{}=1} + {x_{1}}^{2}{y_{2}}^{2} + {x_{2}}^{2}{y_{1}}^{2} - 2x_{1}x_{2}y_{1}y_{2}\\
&= 1 + {x_{1}}^{2}{x_{2}}^{2} + {y_{1}}^{2}{y_{2}}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} + {x_{1}}^{2}{y_{2}}^{2} + {x_{2}}^{2}{y_{1}}^{2}\\
&= 1 + ({x_{1}}^{2} + {y_{1}}^{2}) ({x_{2}}^{2} + {y_{2}}^{2}) - 2x_{1}x_{2} - 2y_{1}y_{2} ,
\intertext{and}
\vert z - a \vert^{2} &= \vert x_{2} - x_{1} + i(y_{2} - y_{1}) \vert^{2} \\
&= {x_{1}}^{2} + {x_{2}}^{2} + {y_{1}}^{2} + {y_{2}}^{2} - 2x_{1}x_{2} - 2y_{1}y_{2} .
\end{align*}

\end{document}

enter image description here

You have a lot of parentheses which are not really needed. Here is my way:

\documentclass[draft,a4paper,landscape]{amsart}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{mathtools}

\begin{document}

\noindent $a = x_1 + iy_1$ and $z = x_2 + iy_2$.
\begin{align*}
\left| 1 - \overline{a}z \right|^2 &= \left| 1 - x_1x_2 - y_1y_2 + i\left(x_1y_2 - x_2y_1\right) \right|^2 \\
&= 1 + x_1^2x_2^2 + y_1^2y_2^2 - 2x_1x_2 - 2y_1y_2 + 2x_1x_2y_1y_2 \\
&\phantom{{}=1} + x_1^2y_2^2 + x_2^2y_1^2 - 2x_1x_2y_1y_2\\
&= 1 + x_1^2x_2^2 + y_1^2y_2^2 - 2x_1x_2 - 2y_1y_2 + x_1^2y_2^2 + x_2^2y_1^2\\
&= 1 + \left(x_1^2 + y_1^2\right) \left(x_2^2 + y_2^2\right) - 2x_1x_2 - 2y_1y_2 ,
\shortintertext{and}
\left| z - a \right|^2 &= \left| x_2 - x_1 + i\left(y_2 - y_1\right) \right|^2 \\
&= x_1^2 + x_2^2 + y_1^2 + y_2^2 - 2x_1x_2 - 2y_1y_2 .
\end{align*}

\end{document}

enter image description here

share|improve this answer
    
I did not expect "&\phantom{{}=1}" to give the alignment of the plus signs in the one expression that is written on two lines. The previous line starts with "= 1 + x_{1}^{2} x_{2}^{2}" and the following line starts with "+ x_{1}^{2} y_{2}^{2}". The alignment marker is at "=". I would expect that "\phantom{{}=1}" would move the "+" only to the right of "1" but it moves the "+" to the right of "1" and the extra space on either side of a binary operator. –  user60254 Aug 9 at 19:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.