# How to align terms in alignat environment

These are my math equations. 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}


Conveniently, mathtools provides \mathllap: \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.

Here you go. Don't worry, I still get confused by alignat myself :). For guidance on how to use alignat effectively, I refer you to egreg's answer to Aligning equations with text with alignat. \documentclass[10pt]{article}

\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}

• I always have trouble in understanding where to put ampersands in multiple alignment in math environment. Thanks for a quick response! – user19906 Jan 11 '14 at 17:40
• @user19906 See my edit. – jub0bs Jan 11 '14 at 18:04