Alignment of equals sign in multiple align environments
From the amsmath
documentation:
The command
\intertext
is used for a short interjection of one of two lines of text in the middle of a multiple-line display structure ... Its salient feature is preservation of the alignment, which would not happen if you simply ended the display and then started it up again afterwards.\intertext
may only appear right after a\\
or\\*
command.
So your example would be:
\begin{align*}
foo &= something very very long compared to the other align \\
\intertext{explanation what I shall do now}
foo' &= foo + short
\end{align*}
The breqn
package also has this capability via its dsuspend
environment.
(Added in edit) From the comments, there appear to be a few different ways to achieve this effect. So to help with choosing, here's a sample of all those that I'm aware of. Anyone who knows more is welcome to either add directly to this answer or to make a comment and then I'll add it. Here's the result:
and here's the code that produced it:
\documentclass{article}
\thispagestyle{empty}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{breqn}
\begin{document}
\paragraph{Two aligns}
\begin{align*}
\begin{vmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{vmatrix}
&= a e i + b f g + c d h - a f h - b d i - c e g
\end{align*}
%
Whilst for \(2 \times 2\) we have:
%
\begin{align*}
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}
&= a d - b c
\end{align*}
\paragraph{One align, intertext preceeded by \textbackslash\textbackslash}
\begin{align*}
\begin{vmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{vmatrix}
&= a e i + b f g + c d h - a f h - b d i - c e g \\
%
\intertext{Whilst for \(2 \times 2\) we have:}
%
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}
&= a d - b c
\end{align*}
\paragraph{One align, intertext not preceeded by \textbackslash\textbackslash}
\begin{align*}
\begin{vmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{vmatrix}
&= a e i + b f g + c d h - a f h - b d i - c e g
%
\intertext{Whilst for \(2 \times 2\) we have:}
%
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}
&= a d - b c
\end{align*}
\paragraph{One align, shortintertext (mathtools)}
\begin{align*}
\begin{vmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{vmatrix}
&= a e i + b f g + c d h - a f h - b d i - c e g
%
\shortintertext{Whilst for \(2 \times 2\) we have:}
%
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}
&= a d - b c
\end{align*}
\paragraph{Using dsuspend from breqn}
~
\begin{dgroup*}
\begin{dmath*}
\begin{vmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{vmatrix}
= a e i + b f g + c d h - a f h - b d i - c e g
\end{dmath*}
\begin{dsuspend}
Whilst for \(2 \times 2\) we have:
\end{dsuspend}
\begin{dmath*}
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}
= a d - b c
\end{dmath*}
\end{dgroup*}
\end{document}
I'd like to throw in a (e)plain-version as well:
\input eplain % merely for the command below
\leftdisplays % for making the picture smaller
$$ \def\vmatrix#1{\left|\matrix{#1}\right|}
\eqalignno{
\vmatrix{a&b&c\cr d&e&f\cr g&h&i} &= aei + bfg + cdh - afh - bdi - ceg \cr
\noalign{\hbox{Whilst for $2 \times 2$ we have:}} % break away from the align
\vmatrix{a&b\cr c&d} &= ad - bc
}
$$
\bye
The following example shows a manual way of achieving the desired alignment between equation (1) and (2):
\documentclass{article}
\usepackage{mathtools}
\begin{document}
Given that
\begin{equation}
\text{Long left-hand side} = \mathrlap{a}
\phantom{\text{Long right-hand side}.}
\end{equation}
where
\[
b = \text{Some weird definition},
\]
it should be clear that
\begin{equation}
\phantom{\text{Long left-hand side}}
\mathllap{c} = \text{Long right-hand side}.
\end{equation}
\end{document}
The above example attempts to align two equations - (1) and (2) - with an additional, ad-hoc, alignment in-between (for whatever reason). The principle of this approach is to identify the longest item on the left-hand and right-hand side respectively, and add them as \phantom
s to the equations that have shorter such sides. \mathllap
and \mathrlap
(from mathtools
) provides the means to sneak in the shorter side visually over-top of the \phantom
placement.
This approach might be helpful when the content inserted between the two alignments fail under \intertext
or \shortintertext
.