7

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}
user19906
  • 1,415

2 Answers2

12

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.

enter image description here

\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}
jub0bs
  • 58,916
8

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.

Werner
  • 603,163