Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

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.

share|improve this answer
add comment

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}
share|improve this answer
    
I always have trouble in understanding where to put ampersands in multiple alignment in math environment. Thanks for a quick response! –  user19906 Jan 11 at 17:40
    
@user19906 See my edit. –  Jubobs Jan 11 at 18:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.