Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
2  
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

1 Answer 1

up vote 9 down vote accepted

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:

Sample output

\documentclass[a4paper]{article}

\usepackage{lipsum}
\usepackage{geometry}
\newenvironment{preface}{\clearpage\setlength{\topskip}{0pt}%
  \newgeometry{vmargin=0cm,ignoreheadfoot}%
  \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

top of page 3

and bottom

bottom of page 3

demonstrating that our rule of 295mm is vertically centered.

share|improve this answer
    
(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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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