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.

I have multiple align environments in my document, separated by a small paragraph of text:

\begin{align*}
  foo &= something very very long compared to the other align
\end{align*}
explanation what I shall do now
\begin{align*}
  foo' &= foo + short
\end{align*}

As the text in the second align is considerably shorter, the = signs don't line up, which is to be expected.

Is there some way to make the two equals signs line up with eachother?

share|improve this question

2 Answers 2

up vote 17 down vote accepted

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:

variations on a theme of intertext

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}
share|improve this answer
1  
Also note the \shortintertext from mathtools. Often \intertext produces excessive vertical spacing (in particular if the text is short). –  Villemoes Feb 23 '11 at 23:41
    
@Villemoes: Very useful to know; I rarely use \intertext because of the excessive spacing. –  Loop Space Feb 24 '11 at 8:41
    
@Herbert, @Villemoes: I've added a sample showing the various possibilities. Thanks for your comments. –  Loop Space Feb 24 '11 at 8:51
    
I think mathtools automatically loads amsmath. –  In PSTricks we trust Sep 2 '13 at 2:32

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

breakalign

share|improve this answer

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.