# Vertical space on top and bottom of inserted image not being equal with vfill?

I have a title page, which used a \vfill from the middle of the page, to push a line of text to the bottom. I inserted an image in this page, and wanted it place in the middle (vertically) between middle-of-page and the bottom text, and so inserted another \vfill there. This, however, doesn't seem to make the spaces on top and bottom of the images exactly equal.

I think that is somewhat demonstrated on this MWE:

\documentclass{book}
\usepackage{filecontents}
\begin{filecontents*}{test-image.tex}
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%\draw[thick] (0,0) rectangle (3cm,3cm);
\draw[line width=2mm] (2.8cm,1.5cm) arc [start angle=0, end angle=-240, radius=13mm];
\end{tikzpicture}
\end{document}
\end{filecontents*}

\immediate\write18{pdflatex test-image.tex}

\usepackage{graphicx}
\usepackage[
paperwidth=15cm,
paperheight=20cm,
outer=2cm,
inner=2cm,
top=2cm,
bottom=2cm
]{geometry}
\usepackage[a4,center]{crop}
\crop[cam,info] % info is default, noinfo has to be set; use [off] to turn off all marks

\usepackage{lua-visual-debug}

\begin{document}

\frontmatter
\begin{titlepage}
\begin{center}
{\Huge Testing the testing test, of the testing test}
\end{center}
%
\vspace{4 cm}
\begin{center}
{\large
Line One
}\\
\vspace{0.2cm}
{\Large
Line Two
}
\end{center}
% BOTTOM PART
\vfill
\begin{center}                                  % INSERT
\includegraphics[width=4.75cm]{test-image.pdf}  % INSERT
\end{center}                                    % INSERT
\vfill                                          % INSERT
\begin{center}
The bottom line is here.
\end{center}
\end{titlepage}
\end{document}


Compile this with lualatex -shell-escape test.tex. The resulting PDF I opened in inkscape, and added dimension lines and their length in what Inkscape sees as millimeters, and got this (note Inkscape corrupted some of the fonts; click for high-res):

So, the top and bottom length should be equal, but the top is 18.34 mm and the bottom is 19.72 mm in height (and in my actual example, I think I have an even more extreme difference, I just couldn't reconstruct it here).

Basically, the way I understand \vfill, if there are two \vfills, since they are of the same "order of infinity", the remaining space should be equally split between them; but apparently, there is a difference. Why does this difference occur - and how could I position the inserted logo, so the vertical spaces above and below it will be exactly equal?

• You're measuring it wrongly: there's the interline skip between the image and the last line, in addition to the extensible space. The interline space, since the depth of the image is zero, is 3.6pt, which means 1.27mm. The difference of 0.11mm should not be considered. – egreg May 7 '15 at 21:13
• Thanks for that @egreg - I completely forgot about the interline skip, and you are right, in this example it matches up; but I was trying this as illustration for my real case where that difference is about 3-4 mm, which I unfortunately couldn't reconstruct here. Cheers! – sdaau May 7 '15 at 21:20
• @egreg: There's just one more thing that bothers me: the discrepancy is not just 0.11mm, but a bit higher, because the image too is preceded by the \lineskip glue. Edit: …as the following answer points out (I have read it just now :-) . – GuM May 7 '15 at 21:56
• @GustavoMezzetti Yes, mine was just a quick computation; the details depend on the height of the line following the image (and also to the lineskip before the image, of course). – egreg May 7 '15 at 21:58

## 1 Answer

The problem is that you must think about the way how TeX puts the boxes in vertical list. Imagine that the \vfill is removed from there, i.e. there is zero space. Then your first space (measured as 18.34mm) will be 1pt, because the following box is unable to fit to the baseline grid, so \interlineskip is inserted here. Plain TeX sets this register to 1pt (I don't know how the register is set in LaTeX but I hope that this is something similar). And the second space will be \baselineskip minus the height of the bottom line. Typical line with 10pt font has the height about 7pt and \baselineskip is set to 12pt. So, the space (measured here as 19.72mm) will be about 5pt. Now add the same amount from \vfill to both spaces. Of course the second space will be greater about 4pt, i.e. about 1.4mm.

If you need to have exactly the same spaces (measured as you show) then you can insert \nointerlineskip before the box with the picture and before the box with the last line.

• Thanks for that @wipet - this answers the question as posed; though in my real case (which I couldn't exactly reconstruct) I get a difference of about 3-4 mm, which (probably) cannot be accounted for with this explanation alone. But then, I guess I better come up with a better MWE then. Thanks again - cheers! – sdaau May 7 '15 at 21:23
• I think in cases like this only \showlists can give adequate insight. – GuM May 7 '15 at 22:05
• I was just curious and, this evening, I've eventually found the time to run the \showlists trial: there's the usual \lineskip glue, 1.0pt, above the picture and a \baselineskip glue of 5.05556pt above the bottom line. The difference of 4.05556pt equals 1.42537mm. A twentieth of millimeter still to be explained… ;-) – GuM May 8 '15 at 21:50