If you put an accent over a single character, TeX uses information in the font metrics to shift the accent to take some account of the slope of the italic letters. Which is why the first one shifts. If you put an accent over a more complicated math list then it's just centered over the list.
I guess you are looking for the following layout
Change
\MoveEqLeft[2] \abs{xy + xz + yz}^{2} \\
to
\mathmakebox[2em][l]{\abs{xy + xz + yz}^{2}}
Then \abs{xy + xz + yz}^{2}
is set in a 2em
width mathbox.
Code:
\documentclass[10pt]{amsart}
\usepackage{mathtools}% loads amsmath
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\begin{document}
\begin{alignat*}{3}
\mathmakebox[2em][l]{\abs{xy + xz + yz}^{2}}\\
&= 3 &&+ \bigl[&&\cos(2a + b + c) + \cos(a + 2b + c) + \cos(a + b + 2c) \\
&&&&&+ \cos(a - b) + \cos(a - c) + \cos(b - c)\bigr] \\
&&&+ \bigl[&&\cos(a - b) + \cos(a - c) + \cos(b - c) \\
&&&&&- \bigl(\cos(2a + b + c) + \cos(a + 2b + c) + \cos(a + b + 2c)\bigr) \bigr] \\
&= 3&&\mathrlap{{}+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).}
\intertext{Likewise,}
\mathmakebox[2em][l]{\abs{x + y + z}^{2}} \\
&= \mathrlap{[\cos a + \cos b + \cos c]^{2} + [\sin a + \sin b + \sin c]^{2}} \\
&= 3 &&\mathrlap{{}+ 2\cos a\cos b + 2\cos a\cos c + 2\cos b\cos c} \\
&&&\mathrlap{{}+ 2\sin a\sin b + 2\sin a\sin c + 2\sin b\sin c} \\
&= 3&& + \bigl[&&\cos(a + b) + \cos(a + c) + \cos(b + c) \\
&&&&&+ \cos(a - b) + \cos(a - c) + \cos(b - c)\bigr] \\
&&&+ \bigl[&&\cos(a - b) + \cos(a - c) + \cos(b - c) \\
&&&&&- \bigl(\cos(a + b) + \cos(a + c) + \cos(b + c)\bigr) \bigr] \\
&= 3&&\mathrlap{{}+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).}
\end{alignat*}
\end{document}
All align...
environments work like tables with a couple of rl
column pairs. The &
have a similar meaning as in tables.
Here is a picture to show how \mathmakebox[2em][l]{...}
and \mathrlap{...}
work.
There are three rl
column pairs. Because the second and the third r
column is completely empty their column width in the alignat*
environment is 0pt.
The green boxes show the real width of the arguments of \(math)makebox[2em][l]{...}
in the first line and \(math)rlap{...}
in the last line. But the red boxes show the used width for this boxes: in the first line 2em
and in the last line 0pt
(and of course the width of the red lines) . The additional width of the contents is simple ignored and does not influence the width of the columns.
In the following picture you can see what happens if \(math)makebox[2em][l]{...}
and \(math)rlap{...}
are removed
Code for the first picture:
\documentclass{article}
\usepackage{mathtools}% loads amsmath
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\usepackage{array}
\usepackage[table]{xcolor}
\arrayrulecolor{gray}
\renewcommand\arraystretch{1.5}
\setlength\fboxsep{0pt}
\setlength\fboxrule{.5mm}
\begin{document}
\begin{tabular}{|*{3}{@{}r@{}|@{}l@{}|}}
r&l&&l&&l\\[2\baselineskip]
\hline
\fcolorbox{red!}{white}{\makebox[2em][l]{\fcolorbox{green}{white}{$\abs{xy + xz + yz}^{2}$}}}&&&&&\\
&$= 3 $&&$+ \bigl[$&&$\cos(2a + b + c) + \cos(a + 2b + c) + \cos(a + b + 2c)$ \\
&$= 3$ &&$+ \bigl[$&&$\cos(2a + b + c) + \cos(a + 2b + c) + \cos(a + b + 2c)$ \\
&&&&&$+ \cos(a - b) + \cos(a - c) + \cos(b - c)\bigr]$ \\
&&&$+ \bigl[$&&$\cos(a - b) + \cos(a - c) + \cos(b - c)$ \\
&&&&&$- \bigl(\cos(2a + b + c) + \cos(a + 2b + c) + \cos(a + b + 2c)\bigr) \bigr]$ \\
&$= 3$&&\fcolorbox{red}{white}{\rlap{\fcolorbox{green}{white}{${}+ 2\bigl(\cos(a - b) + \cos(a - c) + \cos(b - c)\bigr).$}}}&&
\end{tabular}
\end{document}
Best Answer
Here is one way to use the
alignat
environment:Notes:
\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.\mathrlap
to ensure that portions of some lines did not affect the alignment in the other lines.&
provides ar
andl
alignment point, double&&
are used for all subsequent alignment points so that the text following the&&
is left aligned.References:
Code: