# How do I center entire content of a page vertically?

I am using MacTex distribution of Tex, and using xetex for extended font support. My document class is 'article', and I am typesetting a booklet.

I can't seem to find solution on how to center a preface (consisting of multiple paragraphs on its own page) vertically within its page.

I have defined an environment to reuse preface formatting:

\newenvironment{preface}{\thispagestyle{empty}\topskip0pt\vspace*{\fill}\small}{\vspace*{\fill}}


As you can see, my prefaces (i am planning multiple booklets with same style) use smaller text, 'empty' page style and attempt to center vertically.

I have to say the above does attempt to center the content, but it is more top heavy than it should be. I want equal amount of space above the content and below it. How do I accomplish that, in the most straightforward way (if possible avoiding complex tex macros)?

### Minimal working example:

\documentclass[a5paper]{article}
\newenvironment{preface}{\thispagestyle{empty}\topskip0pt\vspace*{\fill}\small}{\vspace*{\fill}}
\begin{preface}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed rhoncus eros et eros varius adipiscing.

In fringilla, enim quis sagittis fringilla, lorem nulla aliquet purus, id malesuada elit mauris vitae nunc. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer ut fermentum sem. Maecenas dapibus elit sit amet laoreet pellentesque.

Integer nec euismod lectus, eget rutrum lacus. Suspendisse imperdiet auctor turpis. Integer congue condimentum nisl, eu ultrices felis facilisis ac. In hac habitasse platea dictumst. Nam at cursus eros, at posuere tellus. Vivamus ipsum nibh, pellentesque non lacinia nec, porta sed sapien. Suspendisse egestas velit ante, ut iaculis augue sollicitudin eget.
\end{preface}
\end{document}

-
Welcome to TeX.SX! The preface is centered with respect to the text block, as far as I can see. Can you add a minimal working example (MWE)? –  egreg Jan 18 at 15:56
Simply because you have different margins at top and bottom. –  Masroor Jan 18 at 15:59

By default page margins at the top and bottom differ. You can use the geometry package, with its commands \newgeometry and \restoregeometry, to control the layout of this page. In particular setting vmargin together with ignoreheadfoot will give a vertically centered text block. However as Heiko Obertdiek points out there is still \topskip present and an initial inter line skip, so these need to be removed too:

\documentclass[a4paper]{article}

\usepackage{lipsum}
\usepackage{geometry}
\newenvironment{preface}{\clearpage\setlength{\topskip}{0pt}%
\thispagestyle{empty}%
\vspace*{\fill}\nointerlineskip\small}%
{\vspace*{\fill}\clearpage\restoregeometry}

\begin{document}

\lipsum[1]

\begin{preface}
\lipsum[2-6]
\end{preface}

\begin{preface}
X\vrule height 295mm Y
\end{preface}

\lipsum[5]
\end{document}


Page 3 of this document is just for illustration. A4 paper is 297mm high. Page 3 has top

and bottom

demonstrating that our rule of 295mm is vertically centered.

-
(For perfectionists:) An analysis with \showlists shows that there are additional white spaces at the top that needs removing or compensating by \setlength{\topskip}{0pt}\vspace{-\parskip}\nointerlineskip. (The latter removes a remaining \baselineskip.) –  Heiko Oberdiek Jan 18 at 16:43
@HeikoOberdiek Many thanks for pointing this out. Code now updated. –  Andrew Swann Jan 19 at 10:17