# center pages vertically automatically

I have a bunch of graphics and text on pages that I would like to automatically center vertically. In some cases there is extra whitespace due to page breaks that leave a large amount of footer space that makes the page look top heavy. I do not want to manually add vertical space since the organization of graphics and text may change forcing me to update all the vfill's or vspace.

Is there a way to have tex this for me behind the scenes?

-

Yes, there is. You need to define \@texttop and \@textbottom. These are used in the LaTeX kernel output routine and can contain skip lengths.

\documentclass{article}
\usepackage{lipsum}
\usepackage{graphicx,alltt}
\makeatletter
\def\nobottom{%
\def\@texttop{\ifnum\c@page>0\vskip \z@ plus 3fil\relax\fi}
\def\@textbottom{\ifnum\c@page>0\vskip \z@ plus 2fil\relax\fi}}
\nobottom
\begin{document}
\lipsum[1]
\clearpage
\lipsum[1-2]
\clearpage
\begin{alltt}
This can be a poem
to see how it will
print
\end{alltt}
\end{document}


See Use of \@texttop and \@textbottom for vertical positioning for a more technical explanation.

-
how do I reset to the original though? –  AbstractDissonance May 24 '12 at 17:27
@AbstractDissonance Maybe write another macro \resetopandbottom which sets the values to the original LateX skips \vskip 0pt plus .00006fil. –  Yiannis Lazarides May 24 '12 at 18:16