# How to get \baselineskip instead of \lineskip when using a stored box?

Consider this code:

\documentclass{article}
\begin{document}
\pagestyle{empty}

\def\contents{%
\parindent = 0pt
\LARGE
\strut
\raise\baselineskip
\vtop
{%
{\Large\smash{Chapter}\par}%
title\par
}%
\par
}
\newbox\tempbox

\loggingoutput

\vspace*{20pt}%
\begingroup
\contents
\endgroup

\clearpage

\vspace*{20pt}%
\setbox\tempbox\vbox
\bgroup
\contents
\egroup
\noindent \box \tempbox

\end{document}


The \contents are supposed to be the a chapter heading, with Chapter written in one line and the chapter title in the line below.

I use that \raise\baselineskip\vtop{...} contraption to allow me to remove the Chapter text from starred chapters but still have the chapter titles in the same vertical position of the page.

All was fine until I needed to set this chapter head in a box before putting it on the output page. I thought that simply enclosing the whole thing in a \vbox to use later with \box would work, but I wouldn't be asking here if it did :)

The log shows this for the first page:

...\glue 20.0
...\glue 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 0.0
...\hbox(22.0+6.60007)x345.0


and this for the second:

...\glue 20.0
...\glue 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\lineskip) 1.0
...\hbox(22.0+6.60007)x345.0


the only difference being that in the first one TeX inserts \baselineskip before the contents and in the second it inserts a \lineskip.

Why does it do that? And how to do otherwise?

• Try \unvbox instead of \box. A box only has one baseline. Mar 19 '19 at 21:57
• @JohnKormylo Hm... Seems to work as well. I swear I had a good reason to use \box instead of \unvbox, but I can't remember it right now :P Thanks for the suggestion :-) Mar 19 '19 at 22:15

You have used a \vbox so the reference point is at the bottom line so the box has height 22pt, as this is already more than \baselineskip tex can not ensure \baselineskip space between the reference point of the previous node and that of the box being added so it inserts \lineskip instead. You could use a \vtop instead, which makes it easier to get the correct space at the start (and harder to get the correct space after)
Hmm actually I suppose the main difference here is that in the first case \baselineskip is coming from the large font so it just fits (hence gets added as 0pt) but in the second case the large font is inside the box so you are using a small baselineskip.
you get \baselineskip (0pt) with
{\LARGE\noindent \box \tempbox\par}

• Hm... Setting the font to \LARGE seems to to the job. Thanks :-) One more thing (about your edited out suggestion): If I were to use \vtop instead of \vbox, is there an easy way to force TeX into using either \baselineskip or \lineskip every time? Mar 19 '19 at 22:10
• @PhelypeOleinik the two things are different \baselineskip is a target reference to reference space so the amount added depends on the depth of the previous line and the height of this, \lineskip is just an "emergency padding that tex adds to stop lines touching if baseline spacing can not be maintained. you can use \nointerlineskip before the line then neither is added and you can add an explicit vkip. Mar 19 '19 at 22:18
• Yes, but in my imagination there would be a to coerce TeX into using one or another to compute the vertical glue. But for now \nointerlineskip will do (If I knew about it I forgot). Thanks :-) Mar 19 '19 at 22:25
• @PhelypeOleinik you can set \lineskiplimit to be -\maxdimen but then it will always use \baselineskip so if the height of the row being added is more then that it will add negative space making the lines overprint, forcing the reference point of the new line to be \baselineskip below the previous. So you can force \baselineskip` if you really want that but it is very rarely useful. Mar 19 '19 at 22:30