# Why does a parbox of height zero consume vertical space?

Assume we have a document where we have one paragraph of text, followed by two vspace boxes, followed by another paragraph of text. I thought that I could insert a parbox with zero height between the vspace boxes without increasing the space between the paragraphs. After all, it would have a height of zero. However, my assumption was not correct and thus my question is where the additional space comes from.

\documentclass[11pt]{article}
\usepackage{blindtext}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}

\blindtext

\vspace{1cm}

\parbox[c][0pt]{\linewidth}{} % When we add this line, the space between both paragraphs increases

\vspace{1cm}

\blindtext

\end{document}


Below you can see screenshots of the compiled documents (first row) and in the second row I drew how that boxes I think should look like. The first column depicts the situation when we replace the parbox with a simple string. Of course, that text consumes some space. The second column depicts the situation I expected when inserting the parbox. Technically, we get a new line between the vspace boxes, but since this line has height and depth zero above and below the baseline, the line "collapes" and the space does not increase. The third column finally depicts the situation as it is. It seems that the zero-height parbox introduces additional space of exactly one baselineskip. Why is that the case and where exactly is the baseline placed within that box with a height of baselineskip? I thought that the distance between the baseline of the new line and bottom edge of the upper vspace box is determined by the element with the highest height in that line (just like the "L" in column 1 of the picture).

• Unrelated: I don't know, but since \par ends the line and the paragraph, I would expect a \baselineskip + \parskip (default in the standard classes=0pt plus1pt) for the next paragraph to start. Unrelated2: width can also be 0: try \fbox{\parbox[c][0pt]{0pt}{x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x }}. – Cicada Dec 20 '20 at 6:33

Let's minimize the example

\documentclass{article}

\pagestyle{empty}

\showoutput

\begin{document}

Test

\vspace{30pt}% so we can see it better in the output

\parbox[c][0pt]{\linewidth}{}

\vspace{30pt}

Test

\end{document}


In the console output we see

Completed box being shipped out [1]
\vbox(633.0+0.0)x407.0
.\glue 16.0
.\vbox(617.0+0.0)x345.0, shifted 62.0
..\vbox(12.0+0.0)x345.0, glue set 12.0fil
...\glue 0.0 plus 1.0fil
...\hbox(0.0+0.0)x345.0
..\glue 25.0
..\glue(\lineskip) 0.0
..\vbox(550.0+0.0)x345.0, glue set 455.9513fil
...\write-{}
...\glue(\topskip) 3.16669
...\hbox(6.83331+0.0)x345.0, glue set 311.33333fil
....\hbox(0.0+0.0)x15.0
....\OT1/cmr/m/n/10 T
....\kern-0.83334
....\OT1/cmr/m/n/10 e
....\OT1/cmr/m/n/10 s
....\OT1/cmr/m/n/10 t
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue 30.0
...\glue 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 9.5
...\hbox(2.5+0.0)x345.0, glue set 330.0fil
....\hbox(0.0+0.0)x15.0
....\mathon
....\vbox(2.5+-2.5)x0.0
.....\glue 0.0 plus 1.0fil minus 1.0fil
.....\glue 0.0 plus 1.0fil minus 1.0fil
....\mathoff
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue 30.0
...\glue 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 5.16669
...\hbox(6.83331+0.0)x345.0, glue set 311.33333fil
....\hbox(0.0+0.0)x15.0
....\OT1/cmr/m/n/10 T
....\kern-0.83334
....\OT1/cmr/m/n/10 e
....\OT1/cmr/m/n/10 s
....\OT1/cmr/m/n/10 t
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue 0.0 plus 1.0fil
...\glue 0.0
...\glue 0.0 plus 0.0001fil
..\glue(\baselineskip) 30.0
..\hbox(0.0+0.0)x345.0


The \parbox corresponds to

....\hbox(0.0+0.0)x15.0                  % <- indent
....\mathon                              % <- start math mode
....\vbox(2.5+-2.5)x0.0                  % <- a \vbox from \vcenter
.....\glue 0.0 plus 1.0fil minus 1.0fil  % <- the glue for vertical centering
.....\glue 0.0 plus 1.0fil minus 1.0fil  % <- the glue for vertical centering
....\mathoff


because the [c] option uses internally math mode to do \vcenter and the actual height and depth are 2.5pt (because of the standard height of the formula axis). However, the explanation lies just before this part, namely

....\glue(\parfillskip) 0.0 plus 1.0fil     % <- the paragraph for Test has ended
....\glue(\rightskip) 0.0                   % <- no \rightskip
...\glue 30.0                               % <- the \vspace{30pt}
...\glue 0.0                                % <- from \vspace implementation
...\glue(\parskip) 0.0 plus 1.0             % <- a paragraph has started
...\glue(\baselineskip) 9.5                 % <- vertical glue
...\hbox(2.5+0.0)x345.0, glue set 330.0fil  % <- a line


The final \hbox is what encloses the \parbox and is preceded by glue from \baselineskip in the amount of 9.5pt: indeed, the height of the box is 2.5pt and 9.5 + 2.5 = 12 (the value of \baselineskip).

Similarly, you see after the box

....\penalty 10000                                  % <- from \par
....\glue(\parfillskip) 0.0 plus 1.0fil             % <- a paragraph has ended
....\glue(\rightskip) 0.0                           % <- no \rightskip
...\glue 30.0                                       % <- \vspace{30pt}
...\glue 0.0                                        % <- from \vspace
...\glue(\parskip) 0.0 plus 1.0                     % <- a paragraph has started
...\glue(\baselineskip) 5.16669                     % <- glue
...\hbox(6.83331+0.0)x345.0, glue set 311.33333fil  % <- the paragraph for Test


The \penalty 10000 is due to the blank line after \parbox, which ends the paragraph.

If you do \parbox[c][0pt]{\linewidth}{X}, then you'd see more: an Overfull \hbox message, due to the indentation being followed by a box that make more the line width. However the vertical spacing between the two instances of “Test” would not change, because the parbox fits vertically in the \baselineskip.

In other words, you have three paragraphs, with added vertical space between them. Actually, the \vspace commands are a kind of red herring. If you consider

\documentclass{article}

\pagestyle{empty}

\begin{document}

Test 1

Test 2

\parbox[c][0pt]{\linewidth}{}

Test 3

\end{document}


you get

It would be different if you used \nointerlineskip\vbox to 0pt{}: here's a side by side comparison:

\documentclass{article}

\begin{document}

\settowidth{\dimen0}{Test 1}

\parbox{\dimen0}{Test 1

Test 2

Test 3}%
\parbox{\dimen0}{Test 1

Test 2

\nointerlineskip\vbox to 0pt{}

Test 3}

\end{document}


• Thanks for this very insightful answer. I'm trying to fully understand it. First, I struggle with \vbox(2.5+-2.5)x0.0. You say that it has height and depth 2.5pt. I'm not familiar with this kind of output, but it looks like it has a positive height and negative depth of 2.5pt. I’m wondering why it has height and depth at all since the parbox is completely empty, and how I should interpret a negative depth? And second, why does the enclosing box have a different height/depth specification (\hbox(2.5+0.0) vs \vbox(2.5+-2.5))? – user1494080 Dec 20 '20 at 13:02
• And another follow-up question: When I position the parbox with t instead of c, I get the following output: ...\glue(\baselineskip) 10.05556 followed by ...\hbox(0.0+0.0)x345.0, glue set 330.0fil Where does the value 10.05556 come from? I would have thought that when the hbox is of height and depth zero, then TeX should take the full 12pt glue from \baselineskip. – user1494080 Dec 20 '20 at 13:37
• @user1494080 The strange notation is due to the fact that the box comes from \vcenter, so it is raised in such a way that the reference point is midway from top to bottom and 2.5pt (the formula axis height) above the baseline. The depth is recorded as negative because the real box height is 0pt, but it's not taken into account for interline glue computations. Sorry, but with \parbox[t][0pt]{\linewidth}{} I get \glue(\baselineskip) 12.0 – egreg Dec 20 '20 at 13:56
• Sorry, I did not only replace c by t, but also the first Test by Testj. Then, the hbox of the first paragraph gets depth 1.94444, and so the \baselineskip consumes only 10.05556. – user1494080 Dec 20 '20 at 14:18
• @user1494080 \makeatletter\check@mathfonts\setlength{\axisheight}{\fontdimen22\textfont2}\makeatother Note that the formula axis height changes with the font size. For just the standard one for normal size, issue the \setlength instruction at begin document: \newlength{\axisheight}\makeatletter\AtBeginDocument{\check@mathfonts\setlength{\axisheight}{\fontdimen22\textfont2}}\makeatother – egreg Dec 20 '20 at 16:49

First it is worth noting that \vspace makes glue not a box, the other half of TeX's box and glue model for text layout.

If I modify your example to

\documentclass[11pt]{article}
\usepackage{blindtext}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}

\blindtext

\vspace{1cm}

%\parbox[c][0pt]{\linewidth}{} % When we add this line, the space between both paragraphs increases
X
%.

\vspace{1cm}

\blindtext

\end{document}


Then it is easier to see what is going on. you have three paragraphs of text two with lipsum, and one with X. The height of a text line does not (normally) depend on the specific characters in the line, if you replace X by . the character is smaller but the middle paragraph takes the same space. The \parbox acts like a zero sized white character so is placed in a one-line paragraph and takes up the same vertical space as any other one line paragraph.

It may be worth noting that the parbox is not \linwidth wide it is of zero width. If you placed any content inside the \parbox such as

\parbox[c][0pt]{\linewidth}{.} %


then you will get an overfull hbox warning as you have a box of width \linewidth indented by \parindent (17pt).