## LaTeX forum ⇒ Math & Science ⇒ Can't set vertical whitespace in the preamble

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

### Can't set vertical whitespace in the preamble

Hi all,

I was redefining vertical whitespace between formulas and text, which is controlled by four lengths, according to Voss' Math mode: \abovedisplayskip, \abovedisplayshortskip, \belowdisplayskip and \belowdisplayhortskip. Surprisingly for me, setting up those lengths in the preamble did nothing, I can only redefine them inside the document. Please test the following example (don't pay much attention to the typeset text ), in which I try to introduce a huge whitespace just before the formula:

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\setlength\parindent{0pt}

% This won't work
\setlength\abovedisplayskip{40pt}

\begin{document}

This is the first line, which just fills space with text before the formula:
$f(x) = \int_0^{\infty} \frac{\sin x}{x}\ dx$
after the formula, this line works as a reference to see the vertical spacing.
\vspace{2\baselineskip}

% This time it will work
\setlength\abovedisplayskip{40pt}

This is the first line, which just fills space with text before the formula:
$f(x) = \int_0^{\infty} \frac{\sin x}{x}\ dx$
after the formula, this line works as a reference to see the vertical spacing.

\end{document}

Could somebody explain me this behavior? Why won't it let me set these lengths in the preamble, while I can set others?

localghost
Site Moderator
Posts: 9203
Joined: Fri Feb 02, 2007 12:06 pm
The values of these lengths are determined by the font size. Hence it is not enough to set them in the preamble.

Best regards
Thorsten¹
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm
Thanks localghost, I understand it now. So, no matter what I put in the preamble, once the document starts these lengths will be reset to a value depending on font size, right? OK, now I know what to do if it happens again with other length commands, thanks!

localghost
Site Moderator
Posts: 9203
Joined: Fri Feb 02, 2007 12:06 pm
Keta wrote:[...] OK, now I know what to do if it happens again with other length commands, thanks! [...]

You must not generalize this for all lengths. The most length registers can be set very well in the preamble. But there may be others apart from these here which can't.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am
Keta,

If you need to set \abovedisplayskip in the preamble, write there a line like
\AtBeginDocument{\setlength\abovedisplayskip{40pt}}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm
Thanks Juanjo, very helpful!

Stefan Kottwitz
Posts: 9705
Joined: Mon Mar 10, 2008 9:44 pm
Hi Keta!

Commands like \normalsize, \small and \footnotesize could change the length of \abovedisplayskip, \belowdisplayskip etc. You could read it for example in bk12.clo in the directory where the LaTeX base classes are located.
Juanjos approach could work, but if some macro calls for instance \normalsize the value of \abovedisplayskip etc. would be changed back.

You could redefine \normalsize etc. according to the class. But here's a short way, using this you don't need to rewrite the original definition of \normalsize:
\makeatletter
\makeatother

or alternatively
\expandafter\def\expandafter\normalsize\expandafter{%
\normalsize\setlength\abovedisplayskip{40pt}}


See perhaps Using \expandafter for macro redefinitions.

This will work in the preamble, tested with your example.

Stefan