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?
Adding an empty box like \mbox{}
or \hbox{}
(or \null
for short) before the \vfill
makes it work.
\newpage
\null
\vfill
blabla
\hrule height0pt depth0pt width1pc
; this puts something "solid" in place to anchor the \vfill
but doesn't take up any measurable vertical space.
Commented
Jun 23, 2011 at 12:41
\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.
Commented
Jun 23, 2011 at 12:52
\null
is the same as \hbox{}
, so one of the two is sufficient.
Commented
Sep 1, 2014 at 16:06
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.
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.
~
is a non-breaking space. Just put it at the top of the page:
\newpage
~\vfill
blabla