5

When I start a page with \vspace*, there is an extra space in addition to what I specify in the vspace.

In this example, without the \vspace the top of the first line begins at 1 inch from the top of the page, as expected. When I uncomment the \vspace line, though, the first line begins about 2 1/8" from the top, instead of 2 inches as I would expect.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\begin{document}
%\vspace*{1in}
First line
\end{document}

How, then, do I begin a page with a specified exact amount of blank space?

Thesis title pages with strict university requirements would be one example where this is needed.

  • Precisely \baselineskip. – egreg May 28 '15 at 20:39
  • @egreg Meaning the vspace adds an extra \baselineskip in addition to its argument? – musarithmia May 28 '15 at 20:40
  • Yes, in this particular case. :( – egreg May 28 '15 at 20:43
6

TeX tries to align the base lines of the first line of the pages. The base line of the first element on the page is put with distance \topskip unless the element is larger.

Example without \vspace*:

\documentclass{article}
\usepackage[margin=1in]{geometry}

\showboxdepth=\maxdimen
\showboxbreadth=\maxdimen
\tracingonline=1
\typeout{\noexpand\topskip = \the\topskip}
\typeout{\noexpand\baselineskip = \the\baselineskip}

\begin{document}
% \vspace*{1in}
First line

\showlists
\end{document}

Log output:

\topskip = 10.0pt
\baselineskip = 12.0pt
[...]
### vertical mode entered at line 0
### current page:
\write-{}
\glue(\topskip) 3.05556
\hbox(6.94444+0.0)x469.75502, glue set 414.8105fil
.\hbox(0.0+0.0)x15.0
.\OT1/cmr/m/n/10 F
.\OT1/cmr/m/n/10 i
.\OT1/cmr/m/n/10 r
.\OT1/cmr/m/n/10 s
.\OT1/cmr/m/n/10 t
[...]

The height of the first line is 6.94444 pt, \topskip has value 10 pt, therefore TeX inserts an additional 3.05556 pt at the top of the page to move the base line to the full 10 pt.

Now the example with \vspace*:

### vertical mode entered at line 0
### current page:
\write-{}
\glue(\topskip) 10.0
\rule(0.0+0.0)x*
\penalty 10000
\glue 72.26999
\glue 0.0
\glue(\parskip) 0.0 plus 1.0
\glue(\baselineskip) 5.05556
\hbox(6.94444+0.0)x469.75502, glue set 414.8105fil
.\hbox(0.0+0.0)x15.0
.\OT1/cmr/m/n/10 F
.\OT1/cmr/m/n/10 i
.\OT1/cmr/m/n/10 r
.\OT1/cmr/m/n/10 s
.\OT1/cmr/m/n/10 t

TeX removes glue at the start of the page. The star form \vspace* prevents this by starting with an invisible rule, its height and depth are zero pt. The rule is also the top element and TeX inserts the full \topskip to move the base line of the rule at the same height as the line in of the previous example. Then the glue amount of 72 pt from the argument of \vspace*{1in} follows. A new paragraph starts with the insertion of \parskip (here 0 pt) and the first line is set according to \baselineskip to get equally vertically spaced lines. The amount is 12 pt, the height of the line is 6.94444 pt and the remaining amount of 5.05556 pt is added.

First case: \topskip - ht(first line) = 3.05556 pt

Second case:
  Full \topskip = 10 pt
  \vspace = 1 in = 72.26999 pt
  \parskip = 0 pt
  \baselineskip - ht(first line) = 5.05556 pt
Sum = 1 in + 15.05556 pt

Thus the spacing can be fixed by removing the unwanted spaces:

\vspace*{1in}
\vspace{-\parskip}
\vspace{-\baselineskip}
% next element smaller than \topskip and \baselineskip
  • if the height of the text line is not higher than \baselineskip and \topskip (e.g., usually a normal text line) or
  • if \baselineskip has the same amount as \topskip (the latter is usually smaller and therefore unlikely to happen).

Otherwise the height of the following element needs to be known or measured in order to calculate and compare, which parts of \baselineskip and topskip would be added.

If the height of the first element is larger than both \baselineskip and \topskip, the error will be the difference between them. Then the correct space can be achieved by

\vspace*{1in}
\vspace{-\parskip}
\vspace{-\topskip}
% next element larger than \baselineskip and \topskip

If it is not clear, where the \vspace* will go, then the following also works, if the space is set in the middle of the page:

\vspace{\parskip}
\vspace{\baselineskip}
\vspace*{1in}
\vspace{-\parskip}
\vspace{-\baselineskip}

The first two \vspace are discarded at the top of a new page.

| improve this answer | |
  • Indeed, Plain TeX has \topglue for the top of the page and \vglue for other places; \vglue is the analog of \vspace*. – egreg May 28 '15 at 20:53
  • So, I could do this: \newcommand{\topvspace}[1]{\vspace*{#1}\vspace{-\parskip}\vspace{-\baselineskip}}. Though it sounds like that won't work all the time. – musarithmia May 28 '15 at 20:58
  • @AndrewCashner Yes, this should work most of the time. And the error for the other rarer cases is limited by the difference between \topskip and \baselineskip. – Heiko Oberdiek May 28 '15 at 21:04
  • If using geometry, I suppose I could also issue a new page geometry command to increase the top margin on that page. – musarithmia May 29 '15 at 0:26
  • @AndrewCashner However, changing the geometry of a page requires hard page breaks before and after the page. – Heiko Oberdiek May 29 '15 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.