Exempt portion of equation line from aligning?
eqparbox
allows you to store the lengths of boxes via a <tag>
. Boxes with the same <tag>
are set with the maximum width across all content. Below I use this approach with a newly-defined \eqmathbox[<tag>][<align>]
(default for <align>
is to c
entre the content) to add content to three different <tag>
ged boxes:
\documentclass{article}
\usepackage{eqparbox,xparse,amsmath}
% https://tex.stackexchange.com/a/34412/5764
\makeatletter
\NewDocumentCommand{\eqmathbox}{o O{c} m}{%
\IfValueTF{#1}
{\def\eqmathbox@##1##2{\eqmakebox[#1][#2]{$##1##2$}}}
{\def\eqmathbox@##1##2{\eqmakebox{$##1##2$}}}
\mathpalette\eqmathbox@{#3}
}
\makeatother
\begin{document}
\begin{align*}
\sum_{r = 0}^{n + 1} \binom{n + 1}{r}
&= \eqmathbox[LEFT]{\binom{n + 1}{0}} + \eqmathbox[CENTRE]{\binom{n + 1}{1} + \dots + \binom{n + 1}{n}} + \eqmathbox[RIGHT]{\binom{n + 1}{n + 1}} \\
&= \eqmathbox[LEFT]{1} + \eqmathbox[CENTRE]{\sum_{r = 1}^n \binom{n + 1}{r}} + \eqmathbox[RIGHT]{1} \\
&= 2 + \sum_{r = 1}^n \biggl[ \binom{n}{r} + \binom{n}{r - 1} \biggr]
\end{align*}
\end{document}
Since eqparbox
uses TeX's \label
-\ref
system, you need to compile twice for every change in the content of the maximum width.
try
\documentclass{article}
\usepackage{array,amsmath}
\begin{document}
\[
\begin{array}{>{\displaystyle}c @{{}={}} >{\displaystyle}c @{{}+{}} >{\displaystyle}c @{{}+{}} >{\displaystyle}c}
\sum_{r=0}^{n+1} \binom{n+1}{r}
& \binom{n+1}{0} & \binom{n+1}{1} + \ldots + \binom{n+1}{n} & \binom{n+1}{n+1} \\
& 1 & \sum\limits_{r=1}^n \binom{n+1}{r} & 1 \\
& \multicolumn{3}{>{\displaystyle}l}{
2 + \sum_{r=1}^n\left[\binom{n}{r} + \binom{n}{r-1}\right]
}
\end{array}
\]
\end{document}
Use the [t]
option. Then you do not need to use \multicolumn
many times if you have many subsequent lines.
\documentclass{article}
\usepackage{array,amsmath}
\begin{document}
\begin{align*}
\sum\limits_{r=0}^{n+1} \binom{n+1}{r}
&\begin{array}[t]{@{}>{\displaystyle}c @{{}={}}@{}>{\displaystyle}c @{{}+{}} >{\displaystyle}c @{{}+{}} >{\displaystyle}c}
& \binom{n+1}{0} & \binom{n+1}{1} + \ldots + \binom{n+1}{n} & \binom{n+1}{n+1} \\
& 1 & \sum\limits_{r=1}^n \binom{n+1}{r} & 1 \\
\end{array}\\
&=2 + \sum_{r=1}^n\left[\binom{n}{r} + \binom{n}{r-1}\right]
\end{align*}
\end{document}