# How to globally change the spacing around equations?

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.

-
from your mention of subequations and gather it appears that you are using amsmath. (a mwe would make this more clear.) it is a known bug that, for multi-line equations, \abovedisplayskip is always used instead of \abovedisplayshortskip since multi-line displays are always implemented as a full-width environment. this is scheduled for review and (hoped-for) correction in the next overhaul of amsmath; unfortunately, the overhaul has not yet been firmly scheduled. – barbara beeton Sep 1 '12 at 13:28
possible duplicate of Different spacing around equation and align – Marco Daniel Sep 1 '12 at 14:08
@MarcoDaniel The suggested duplicate is specifically about making spacing of equation and alignment equal. I think in general it's good to close the more specific question as a duplicates to the general one. The order of appearance on TeX.SX doesn't matter at long sight. Or edit the other question to make it canonical. Perhaps you would find another question where the answer doesn't just mention those lengths, but explain it how to adjust it in the preamble globally, overcoming the reset in \normalsize? – Stefan Kottwitz Sep 1 '12 at 17:36

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
\setlength\abovedisplayskip{40pt}
\setlength\belowdisplayskip{40pt}
\setlength\abovedisplayshortskip{40pt}
\setlength\belowdisplayshortskip{40pt}
}
\makeatother
\begin{document}
text
\begin{gather}$$1 + 1 = 2$$\end{gather}
text
$$1 + 1 = 2$$
\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.

-
 @lockstep Added. Btw. I used the opportunity to explain the \normalsize way, because I did not see that one here yet, just adjusting the values and perhaps adding that it should be used after \begin{document}, which isn't the best, such as here. – Stefan Kottwitz♦ Sep 1 '12 at 12:09 @StefanKottwitz -- even with the \expandafters, wouldn't it be "safer" to save the prior value of \normalsize, say \let\originalnormalsize\normalsize, and use that in the definition, rather than \normalsize itself? – barbara beeton Sep 1 '12 at 12:41 @barbarabeeton The \let way is indeed a nice and more understandable way. However regarding being safe, it adds the risk that the additional macro used for saving is already used by a class or package. Not a big deal, just to add it. That's why I tend to use \newcommand*{\origmacro}{} before saving, so at least an error would be raised instead of silently overwriting. – Stefan Kottwitz♦ Sep 1 '12 at 12:50

As an update of Stefan's answer.

Your questions should be closed as duplicated You will find a lot of question/answeres here. E.g.:

Different spacing around equation and align

Before showing some other approaches here a very important fact:

Don't miss the glue! The length \abovedisplayskip etc. can be defined with a glue and so you allow LaTeX to setup the space more flexible. Please read this question/answer: What is glue stretching?

However I want to show an other possibility to setup the length. First of all you can use the command \AtBeginDocument. The font will be setup at the beginning of the document and so the hook will executed the stuff later:

\AtBeginDocument{%
\abovedisplayskip=12pt plus 3pt minus 9pt
\abovedisplayshortskip=0pt plus 3pt
\belowdisplayskip=12pt plus 3pt minus 9pt
\belowdisplayshortskip=7pt plus 3pt minus 4pt
}


The command \g@addto@macro is an internal macro. Packages like etoolbox or the newer one xpatch are providing more robust versions of the command \g@addto@macro. Show instead of using the internal command and without special handling of the @ you can use:

\usepackage{etoolbox}
\apptocmd\normalsize{%
\abovedisplayskip=12pt plus 3pt minus 9pt
\abovedisplayshortskip=0pt plus 3pt
\belowdisplayskip=12pt plus 3pt minus 9pt
\belowdisplayshortskip=7pt plus 3pt minus 4pt
}{}{}


or

\usepackage{xpatch}
\xapptocmd\normalsize{%
\abovedisplayskip=12pt plus 3pt minus 9pt
\abovedisplayshortskip=0pt plus 3pt
\belowdisplayskip=12pt plus 3pt minus 9pt
\belowdisplayshortskip=7pt plus 3pt minus 4pt
}{}{}


That is work with gather here a simple example. You should play with the lengths.:

\documentclass{article}
\usepackage{kantlipsum}
\usepackage{xpatch}
\xapptocmd\normalsize{%
\abovedisplayskip=12pt plus 3pt minus 9pt
\abovedisplayshortskip=0pt plus 3pt
\belowdisplayskip=12pt plus 3pt minus 9pt
\belowdisplayshortskip=7pt plus 3pt minus 4pt
}{}{}
\usepackage{amsmath}
\begin{document}
\kant[1]
\begin{gather}$$1 + 1 = 2$$\end{gather}
\kant[1]
\begin{gather}$$1 + 1 = 2$$\end{gather}
\kant[1]
\begin{subequations}
$$1 + 1 = 2$$
\end{subequations}
\kant[1]
\kant[1]
\end{document}

-
 @User17670: There are no differences for gather or subequations – Marco Daniel Sep 1 '12 at 13:54 @User17670: See edit – Marco Daniel Sep 1 '12 at 13:56 @User17670: As duplicated is more correct because the MWE shows that the lengths will work for gather too. – Marco Daniel Sep 1 '12 at 14:02