Extra space added after equation when it is coloured
Oh. It's an AMS bug, the alignment is not color safe . Never noticed that before:-) In that case you need explicit grouping (use begingroup rather than bgroup or {
as it's rather less intrusive into math spacing)
\documentclass[12pt]{standalone}
\usepackage{amsmath}
\usepackage{color}
\begin{document}
\begin{minipage}{4cm}
\begin{equation*}
a = b + c
\end{equation*}
\begin{align*}
a - b &= c\\
a-c & b
\end{align*}
\end{minipage}
\vline
\begin{minipage}{4cm}
\begin{equation*}
\begingroup\color{blue} a = b + c\endgroup
\end{equation*}
\begin{align*}
a - b &= c\\
a-c & b
\end{align*}
\end{minipage}
\end{document}
It's actually a bit harsh to call it an AMS bug, the same effect is seen with \[
in LaTeX however rather than grouping each case, this is probably the correct fix (anywhere in the preamble after loading amsmath
. I'll ping @barbarabeeton
\def\foo#1$$#2!!{\def\mathdisplay##1{#1$$\begingroup#2}}
\expandafter\foo\mathdisplay{#1}!!
\long\def\foo#1$$#2!!{\def\endmathdisplay##1{#1\endgroup$$#2}}
\expandafter\foo\endmathdisplay{#1}!!
having found david's inquiry about this while cleaning out old files, i have finally investigated.
while there is indeed extra (unwanted) space when two display environments
are adjacent, and this space increases when color is added, the amsmath
display environments are not designed to be used in this manner.
all display material between two blocks of text should instead be placed
into a single environment, which can then be subdivided into "subsidiary"
nested environments as appropriate. (someone mentioned that in a comment,
but it didn't make it into david's answer.) here is an expanded example
showing the desired outcome in the last column. (i've changed blue
to red
because blue tends to disappear on my screen.)
\documentclass[12pt]{standalone}
\usepackage{amsmath}
\usepackage{color}
\begin{document}
\begin{minipage}{4cm}
\begin{equation*}
a = b + c
\end{equation*}
\begin{align*}
a - b &= c\\
a-c &= b
\end{align*}
\end{minipage}
\vline
\begin{minipage}{4cm}
\begin{equation*}
\color{red} a = b + c
\end{equation*}
\begin{align*}
a - b &= c\\
a-c & b
\end{align*}
\end{minipage}
\vline
\begin{minipage}{4cm}
\begin{equation*}
\begingroup\color{red} a = b + c\endgroup
\end{equation*}
\begin{align*}
a - b &= c\\
a-c &= b
\end{align*}
\end{minipage}
\vline
\begin{minipage}{4cm}
\begin{gather*}
\begingroup\color{red} a = b + c\endgroup\\
\begin{split}
a - b &= c\\
a-c &= b
\end{split}
\end{gather*}
\end{minipage}
\end{document}
so is this a bug in amsmath
? if this extra space appears when a "simple"
one-environment instance comes between two text blocks, then it is definitely
a bug. if there is no extra space in that context, then it's not a bug,
since the behavior is what amsmath
is designed to do. here's the example
to decide the matter.
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{color}
\begin{document}
start with some text. make it a rather long line.
\begin{equation*}
a = b + c
\end{equation*}
some more text. make this also a rather long line.
\begin{equation*}
\color{red} a = b + c
\end{equation*}
still more text. make this also a rather long line.
\end{document}
no extra space. thus i interpret the problem as misuse of the environments, and not a bug.