[Tex/LaTex] How to align terms in alignat environment

alignequationshorizontal alignment

These are my math equations.

enter image description here

To enhance readability, I'd like the third column to be aligned around the + sign;
that is,

  • I wish to place some horizontal blank in front of $n\mathbf{A}_0$ (not behind it) in the first line so that there's no blank between $n\mathbf{A}_0$ and + sign.
  • And the same thing for the third line with the space behind $\frac{n 2}\mathbf{A}_2$.
\documentclass[10pt]{document}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{mathtools}

\newcommand{\Abf}{\ensuremath{\mathbf A}}

\begin{document}

\begin{subequations}
\begin{alignat}{3}
\Abf\Abf_1 &= b_0\Abf_0 + c_2\Abf_2 = n\Abf_0 & &+ {\frac n 2}\Abf_2 \\
\Abf\Abf_2 &= b_1\Abf_1 + c_3\Abf_3 = (n-1)\Abf_1 & &+ (n-1)\Abf_3 \\
\Abf\Abf_3 &= b_2\Abf_2 + c_4\Abf_4 = {\frac n 2}\Abf_2 & &+ n\Abf_4
\end{alignat}
\end{subequations}

\end{document}

Best Answer

Conveniently, mathtools provides \mathllap:

enter image description here

\documentclass[10pt]{article}

\usepackage{mathtools}% http://ctan.org/pkg/mathtools

\newcommand{\Abf}{\mathbf{A}}

\begin{document}

\begin{subequations}
  \begin{alignat}{2}
    \Abf\Abf_1 &= b_0\Abf_0 + c_2\Abf_2 = &&            \mathllap{n\Abf_0} + \tfrac{n}{2}\Abf_2 \\
    \Abf\Abf_2 &= b_1\Abf_1 + c_3\Abf_3 =                    (n-1)\Abf_1 &&+ (n-1)\Abf_3 \\
    \Abf\Abf_3 &= b_2\Abf_2 + c_4\Abf_4 = && \mathllap{\tfrac{n}{2}\Abf_2} + n\Abf_4
  \end{alignat}
\end{subequations}

\end{document}

The idea is to set the components that require an adjusted alignment as part of the last "column" of the construction, but with zero width. \mathllap provides a left overlap in math-mode.

Related Question