[Tex/LaTex] How to globally change the spacing around equations

equationsspacing

How could I go about setting the 'above' and 'below' vspaces around the equation environment?

If the same could be done for the subequations or gather environments, this would be a bonus.

Best Answer

You can adjust the values of \abovedisplayskip, \belowdisplayskip, \abovedisplayshortskip, \belowdisplayshortskip. The shortskip versions are used in the situation where a short text line comes before the displayed equation: if the text ends before the displayed equation starts, it's good to add less vertical space.

Since document classes often define those skips in \normalsize you could redefine this macro, patch it, or simply add to it, because just setting the values in the preamble would not work then.

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\g@addto@macro\normalsize{%
  \setlength\abovedisplayskip{40pt}
  \setlength\belowdisplayskip{40pt}
  \setlength\abovedisplayshortskip{40pt}
  \setlength\belowdisplayshortskip{40pt}
}
\makeatother
\begin{document}
text
\begin{gather}
  1 + 1 = 2
\end{gather}
text
\begin{equation}
  1 + 1 = 2
\end{equation}
\end{document}

The same can be done without \g@addto@macro, so without any @ and not requiring \makeatletter and \makeatother, by using \expandafter:

\expandafter\def\expandafter\normalsize\expandafter{%
    \normalsize
    \setlength\abovedisplayskip{40pt}
    \setlength\belowdisplayskip{40pt}
    \setlength\abovedisplayshortskip{40pt}
    \setlength\belowdisplayshortskip{40pt}
}

I prefer the way of adding to \normalsize, because both redefining and patching require knowing the exact definition of \normalsize used by the document class. Bot ways I described earlier in the LaTeX Community forum, in an answer to Can't set vertical whitespace in the preamble.

More information is available in the excellent mathmode documentation.

Related Question