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.

Using \vfill between two texts works:

\newpage
bla
\vfill
blabla

but it doesn't work if there is no text before it:

\newpage
\vfill
blabla

How can this be achieved?

share|improve this question

3 Answers 3

up vote 11 down vote accepted

Adding an empty box like \mbox{} or \hbox{} (or \null for short) before the \vfill makes it work.

\newpage
\null
\vfill
blabla
share|improve this answer
1  
remember that any box will add a blank line, so if the exact height of the fill is important, that must be taken into consideration. a plain-tex alternative to a box is \hrule height0pt depth0pt width1pc; this puts something "solid" in place to anchor the \vfill but doesn't take up any measurable vertical space. –  barbara beeton Jun 23 '11 at 12:41
    
@barbara: Thanks, I actually thought about the introduced height while writing the post and thought to maybe replace \null with \vspace*{0pt}, but didn't wanted to mention it without testing it. Personally I actually like Andrew's suggestion to use \vspace*{\fill} better than my answer. –  Martin Scharrer Jun 23 '11 at 12:52

It's important to understand how TeX's page break mechanism works, at least for the main aspects.

When TeX decides where to break a page, it pushes back to the "list of recent contributions" what doesn't fit in the page and does the break.

Usually what doesn't fit are the final lines of a paragraph, but a break can very well happen at a vertical space (such breaks happen always before the vertical space). Now the break is performed and the vertical space is put back to be reconsidered; but nobody wants to start a normal page with a vertical space, so TeX makes it disappear.

This unless this vertical space is declared with \vspace*: this kind of vertical space is never considered for a break, it's just like a big invisibile character.

How the page break was chosen is irrelevant: this happens even at the start of a document. If you say

\begin{document}
\vspace{3cm}

this vertical space will not appear.

Using \null after \newpage effectively avoids the disappearance of vertical spaces, because \null puts on the page an empty box before the \vspace (something like a zero width and height character).

Thus the "good" way to build a dedication page, for instance, is

\cleardoublepage
\thispagestyle{empty}
\vspace*{\stretch{1}}
\begin{flushleft}
\itshape Dedicated to the people on \TeX.SX\\
         on the occasion of the first birthday\\
         of that wonderful site
\end{flushleft}
\vspace{\stretch{2}}
\cleardoublepage

The \vspace*{\stretch{1}} is actually equivalent to \null\vfill; but specifying the stretching with \stretch allows for nice effects: here the white space after the dedication is twice as much as the space before it.

share|improve this answer

LaTeX provides the macro \vspace for adding an amount of space, \vspace{\fill} has the same effect as \vfill, and has the same failing. LaTeX also provides1 the macro \vspace* for "I really, really do want you to put the space in here." so \vspace*{\fill} works. That is to say,

\newpage
\vspace*{\fill}%
blabla

puts the blabla at the bottom.

1 Actually, \vspace and \vspace* are the same macro, but it's a convenient lie to think of them as variant macros.

share|improve this answer

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.