# Force vertical white space at top and bottom of page to be _exactly_ the same

I am trying to get exact symmetry of leading and trailing vertical white space.

I have a sample 1-page document with a top line containing the dummy text "ABCDE", some dummy vertical space, and a bottom line, also containing the text "ABCDE". My page size is 8.5in by 11in.

The goal is to get the distance from the absolute top of the page to the top of the letter A in the first line to be exactly same as the distance from the absolute bottom of the page to the base of the letter A on the last line.

I tried the following:

\documentclass{article}
\pagenumbering{gobble}
\begin{document}
\topskip=0pt
\vspace*{\fill}
ABCDE
\par
\vspace{7in}
\par
ABCDE
\vspace*{\fill}
\end{document}


but it doesn't quite work.

I want the solution to automatically work for all pages, each with their own amounts of leading and trailing vertical white space. For example, one page may need 4in of leading and trailing space which I want to split as exactly 2in at the top, and 2in at the bottom, and some other page may need only 1.5in of vertical space which I want to split as exactly .75in at the top, and .75in at the bottom.

How can I do this? Thanks in advance.

• Your question isn't so clear where you want the space, especially as your example has a page number. add \usepackage{showframe} to see the block in which your \fill are acting. – David Carlisle May 29 '17 at 16:36
• I meant to turn off page numbers. Thanks, I'll edit the question. – tex_novice May 29 '17 at 16:37
• @David Carlisle: I turned off page numbering, but it still doesn't work -- there's more white space at the top than at the bottom. – tex_novice May 29 '17 at 16:40
• \pagenumbering{gobble} (or better \pagestyle{empty} ) does not change the space allocated for the page foot, it just leaves it blank. – David Carlisle May 29 '17 at 16:55
• It is possible that your measuring strategy is calculating to top of font, rather than top of character. The top of a font is always higher than the height of un-accented capital letters. Likewise, the bottom calculation might be to bottom of font rather than baseline. – user103221 May 29 '17 at 17:26

You can use the geometry package to set the margins symmetrically. If you don't want any margins at all:

\documentclass{article}
\pagenumbering{gobble}

\usepackage[
%showframe,
top=0pt,
bottom=0pt,
paperwidth=8.5in,
paperheight=11in,
]{geometry}

\begin{document}
\topskip=0pt
\vspace*{\fill}
ABCDE
\par
\vspace{10.5in}
\par
ABCDE
\vspace*{\fill}
\end{document}


This package can also be used to set the paper size.

• Thanks a lot -- that works just fine, and very simple, too! Strangely, your version is also off by about 1.5mm, although the excess is now at the top. Ignoring that minor discrepancy, both of the answers posted appear to solve the problem, although yours is simpler, and the paper size comes out at 8.5in by 11in, which is what I need. Thanks again! – tex_novice May 29 '17 at 17:39
• @tex_novice If you are worries about the 1.5mm, maybe try something like top=-1.5mm (no warranty, such a hack might break something...) – samcarter_is_at_topanswers.xyz May 29 '17 at 17:44
• I'll try that, but in any case, I think you have all given fine answers. Much appreciated! – tex_novice May 29 '17 at 17:52
• @tex_novice You're welcome! – samcarter_is_at_topanswers.xyz May 29 '17 at 19:23

I think you mean something like this with no page head or foot, and all content vertically centred.

\documentclass{article}
\usepackage{showframe}
\makeatletter
\let\@textbottom\vfill \let\@texttop\vfill

\setlength\topmargin{-1in}
\setlength\footskip{0pt}
\setlength\paperheight{\textheight}
\AtBeginDocument{\setlength\pdfpageheight{\paperheight}}

\makeatother

\pagestyle{empty}
\def\zz{One two three One two three One two three One two three
One two three One two three One two three One two three
\par
One two three One two three One two three One two three
\par
One two three One two three One two three One two three One two three
\begin{center}\rule{1in}{4in}\end{center}
One two three One two three One two three One two three
\par
One two three One two three One two three One two three
\par
One two three One two three One two three One two three
One two three One two three One two three One two three One two three\par}
\begin{document}
ABCDE
\par
\vspace{7in}
\par
ABCDE
\clearpage

\zz\zz
\end{document}

• why would you ever want to do this? :-) – David Carlisle May 29 '17 at 16:57
• Haha -- I have my reasons! But thanks very much for your answer. I'm testing it now . . . – tex_novice May 29 '17 at 17:03
• It's almost perfect! It's actually off by about 1.5mm (excess is on the bottom), and I guess I can live with that, but isn't tex supposed allow exact measures using extremely tiny units? Also, when I ran your code, the page sizes (in the pdf file) come out to 8.5in by 7.61in, but I need 8.5in by 11in. How can I fix that? – tex_novice May 29 '17 at 17:14
• just set \pdfpageheight (and \textheight) to whatever you need, tex measurements are accurate to thousands of an inch, but trick is to work out what point it is measuring from @tex_novice – David Carlisle May 29 '17 at 17:53
• Cool! I think you've given me all I need to solve this problem, and probably other such issues that may arise in the future. Many thanks! – tex_novice May 29 '17 at 18:00

If you want get exact spaces at the top and at the bottom, specify them.

\documentclass{article}
\usepackage[top=0pt,bottom=0pt,letterpaper]{geometry}

\pagestyle{empty}
\setlength{\topskip}{0pt}

\begin{document}

\vspace*{2in}

ABCDE

\vspace*{\fill}

ABCDE

\vspace*{2in}

\end{document}


You can't do it by specifying the space in the middle, because otherwise the space occupied by the text would go in the supposed margins.

• The only problem with this approach is I don't want to have to measure the pages in advance. I want tex to compute the spacing. – tex_novice May 29 '17 at 17:44
• @tex_novice What do you mean? I can't understand. – egreg May 29 '17 at 17:44
• What I mean is for a given page, I don't know that it should be 2in and 2in. And there will be many such pages, each requiring slightly different spacing. – tex_novice May 29 '17 at 17:45
• But maybe I can use that approach. Let's say I always want at most two inches at top and bottom. Can I tell tex to use that a maximum, and shrink it if necessary (symmetrically, of course)? – tex_novice May 29 '17 at 17:48
• @tex_novice What does the space on top and bottom depends on? If you don't tell, it's guesswork. – egreg May 29 '17 at 18:04