# Why does gather behave this way, and what can we do about it?

Here's a simplified version of the code I'm having trouble with.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}\underline{First set of identities.}\end{center}
$x+x = x$

\begin{center}\underline{Second set.}\end{center} \begin{gather*}
0+x = x, \quad x+0 = 0 \\
(x+y)+z = x+(y+z)
\end{gather*}
\end{document}


Basically, the gather* command is creating more space than the usual [\ \]. Why is gather* doing this, and what can we do about it?

-

It's the center environment not playing well with gather*:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}
\underline{First set of identities.}
$x+x = x$
\end{center}%
\begin{center}
\underline{Second set.}
\begin{gather*}
0+x = x, \quad x+0 = 0 \\
(x+y)+z = x+(y+z)
\end{gather*}
\end{center}
\end{document}


Alternatively, since there seem to be a duplication of skips, you can do an \unskip after the problematic center environment:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}
\underline{First set of identities.}
\end{center}%
$x+x = x$
\begin{center}
\underline{Second set.}
\end{center}\unskip
\begin{gather*}
0+x = x, \quad x+0 = 0 \\
(x+y)+z = x+(y+z)
\end{gather*}
\end{document}

-

I'll present two possible solutions.

1. Don't close the center environment

2. “Abuse” the gather* environment

At the top is the rendering with your input. Note that I removed underlining, which is frowned upon by typographers. Instead of \textbf you can also use \textit.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}\underline{First set of identities.}\end{center}
$x+x = x$

\begin{center}\underline{Second set.}\end{center} \begin{gather*}
0+x = x, \quad x+0 = 0 \\
(x+y)+z = x+(y+z)
\end{gather*}

\bigskip
\hrule
\bigskip

\begin{center}\textbf{First set of identities.}
$x+x = x$
\textbf{Second set.}
\begin{gather*}
0+x = x, \quad x+0 = 0 \\
(x+y)+z = x+(y+z)
\end{gather*}
\end{center}

\bigskip
\hrule
\bigskip

\begin{gather*}
\textbf{First set of identities.}\\
x+x = x \$2ex] \textbf{Second set.}\\ 0+x = x, \quad x+0 = 0 \\ (x+y)+z = x+(y+z) \end{gather*} \end{document}  - You can load the nccmath package. I tried, thinking of using its \useshortskip command and discovered that just loading it works. Note that it loads amsmath, so that you can load it instead of amsmath. It doesn't load mathtools (recommended extension of amsmath), though: \documentclass{article} \usepackage{mathtools} \usepackage{nccmath} \begin{document} \begin{center}\underline{First set of identities.}\end{center} \[x+x = x$

\begin{center}\underline{Second set.}\end{center} %
\begin{gather*}
0+x = x, \quad x+0 = 0 \\
(x+y)+z = x+(y+z)
\end{gather*}

\end{document}


-
Interesting. So it seems that the amsmath gather command has a bug. – goblin Jun 27 '14 at 10:49
It's not the first one since mathtools, by default, fixes two bugs of amsmath. Note that nccmath also has problems under certain circumstances that I don't remember at the moment (never met those problems myself). – Bernard Jun 27 '14 at 11:23