0

I want to ask a question about the \vfill command in LaTeX.

I'm a newcomer/beginner to LaTeX, and I've been learning about making my own title page using the LaTeX Wiki.

I've shown the code below, and the relevant output:

\documentclass[12pt, a4paper]{report}
\usepackage{graphicx}
\begin{document}
\begin{titlepage}
    \centering
    \includegraphics[width=0.15\textwidth]{example-image-1x1}\par\vspace{1cm}
    % \par ends a paragraph
    {\scshape\LARGE Columbidae University \par}
    %   \scshape = smallcapstext
    \vspace{1cm}
    {\scshape\Large Final Year Project \par}
    \vspace{1.5cm}
    % \bfseries = bold frame series
    {\huge\bfseries Pigeons love doves \par}
    \vspace{2cm}
    {\Large\itshape John Birdwatch\par}
    \vfill
    supervised by\par
    Dr.~Mark \textsc{Brown}

    \vfill

    % Bottom of the page
    {\large \today\par}
\end{titlepage}
\end{document}

You can see that there are two instances of \vfill present in the above code.

The following output is also achieved, as expected.

Output from the code in the question

My confusion is that, according to the OverLeaf manual, \vfill inserts a blank space that stretches to fill the available space, and sinks all the elements to the bottom.

However, in the example given above, it appears to place the succeed elements with equal spacing between them. This, evidently, contradicts the definition given above.

How does \vfill function in this code, shown above?

1 Answer 1

3

The "sink to the bottom" part only applies if you have a single vfill at the top, if you have a vfill at the bottom it pushes everything up and if you have a vfill in the middle you get text top and bottom with white space in the middle.

If TeX is using fill glue then it first works out how much extra space is needed on the page then it works out how many units of fill glue are on the page (each \vfill is \vskip 0pt plus 1fill then that space is allocated to each of the skips, each \vfill producing the same space, and the total causing the page to be the required total size.

3
  • Hi David, thank you for your answer! Your answer gives me a lot of clarity, and actually I was thinking along a similar trail of thought earlier when attempting to work out the purpose of vfill, yet I couldn't find a reference to match what you mentioned. I was wondering whether you have a reference available that justifies what you have said, just so I can refer to it in future instances!
    – vik1245
    Feb 13, 2021 at 23:03
  • 1
    @vik1245 \vfill is a tex primitive so the texbook is the official reference but tex by topic is a good free alternative, try texdoc texbytopic section 8.3 more about glue Feb 13, 2021 at 23:05
  • Understood, thanks very much David!
    – vik1245
    Feb 13, 2021 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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