# Vertical centering of text in a page when text contains enumerations

I'd like a vertically centered letter under letterhead, when a letter is less than a page. When a letter is more than a page, I'd like to achieve a minimum spacing between the letter and letterhead.

The format of the documents is:

[Text]
- trailing-space -

I've thought to add \vfill at leading-space and trailing-space. This seems to accomplish what I want for letters of one page. However, when the document is over a page long the leading-space is inappropriately large - notably when there's an enumerate environment in the text.

I'd be grateful for thoughts and suggestions on how to accomplish this vertical spacing for both long and short (one page) letters.

Note that this is similar to Centering text on a page, except I'm not writing poetry. First, I'm using the memoir class, and second I'm not writing poetry – which would seem to make the verse package inappropriate.

I also note that the letter package accomplishes this sort of spacing, though I admit that I looked at the package and did not understand how it did so.

EDIT: The problem seems related to an enumerate. Example code is as follows:

\documentclass[oneside,11pt]{memoir}
\usepackage{lipsum}
\begin{document}

\begin{vplace}
\lipsum[2] % Text
\begin{enumerate}[1.] % more Text (albeit enumerated)
\item{}abc
\item{}ghi
\end{enumerate}\par
\lipsum[3-6] % more Text
\end{vplace}
\end{document}


If one removes the enumerated list, then the vertical spacing of the typesetting comes out as one would expect. However, with the enumerated list there's a very strange and large space between the Letterhead and first paragraph of Text.

What's causing the large space? Is it possible to eliminate it (without removing the enumerated content).

-
If you use \vfil instead of vfill you'll get the spacing you want. See What is the difference between 'fil' and 'fill' –  Alan Munn Aug 18 '11 at 19:08
@doncherry: Memoir's vplace seems to work, except for the case I've noted with the example code I pasted in my edit. –  Brian M. Hunt Aug 18 '11 at 20:09
@Alan Munn: The vfil solution seemingly has the same effect/problem as vplace –  Brian M. Hunt Aug 19 '11 at 16:39

does this help?

\documentclass[oneside,11pt]{memoir}
\usepackage{lipsum}
\begin{document}

\begin{vplace}
\lipsum[2] % Text

\bigskip\noindent
\begin{minipage}{\linewidth}
\begin{enumerate}[1.] % more Text (albeit enumerated)
\item{}abc
\item{}ghi
\end{enumerate}
\end{minipage}  \par\bigskip
\lipsum[3-6] % more Text
\end{vplace}
\end{document}

-
I was going to suggest this as a solution too, but I'm curious as to why the problem arises in the first place. (And as Brian notes in the comments, \vfil shows the same behaviour too.) –  Alan Munn Aug 19 '11 at 17:22
I'm quite curious, too. It seems counterintuitive that wrapping an enumeration in a box would improve the pagination; I'd expect the opposite (if anything) to happen to proper pagination by the TeX algorithms (as enumerations, you'd think, would break at each \item, whereas a minipage would break with less information about the 'break-ability' of its contents (i.e. you'd think minipage would obfuscate the relevant semantics by "hiding" the list's breakable places). Great solution though, @Herbert, but it seems unintuitive (to me)! I'd love to know more. –  Brian M. Hunt Aug 21 '11 at 0:44

The question is interesting. After an enumerate environment, LaTeX puts a negative vertical penalty (-51) which gives a good page break point. When the paragraph following the list is completed, TeX proceeds to examine where to break the page (it exercises the page builder, in the terminology of the TeXbook).

The "least cost break point" is found exactly after the list, because of that negative penalty: the \vspace*{\stretch{1}} provided by the vplace environment supplies the necessary vertical space.

The documentation of the memoir class doesn't tell it very clearly, but vplace should be used only for objects that fit into a page: it just adds infinitely stretchable space before and after it. Indeed it's defined as

\newenvironment{vplace}[1][1]
{\par\vspace*{\stretch{#1}}}
{\vspace*{\stretch{1}}\par}


which is not what you wanted.

Note
The -51 penalty comes from the code of \endtrivlist, where it says \@endparenv, which in turn does \addpenalty\@endparpenalty; \@endparpenalty is set to -\@lowpenalty and \@lowpenalty=51.

-
Thanks for the answer – great insight. In place of vspace, is there an option you would you suggest? Is the vfil/vfill option better in any way? –  Brian M. Hunt Aug 22 '11 at 14:01
With \vfill you'd get the same. –  egreg Aug 22 '11 at 19:50