[Tex/LaTex] Alignment using an alignat{2} environment

alignatamsmathmath-mode

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}

Best Answer

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}