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.

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.

share|improve this question
3  
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
1  
@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

2 Answers 2

up vote 16 down vote accepted

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.

share|improve this answer
    
@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}
\begin{equation}
  1 + 1 = 2
\end{equation}
\end{subequations}
\kant[1]
\kant[1]
\end{document}
share|improve this answer
    
@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

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.