# Will it stretch? Plumbing the depths of Interline glue

I've gone back to basics to gain a better understanding of how TeX works. One of the things I've been puzzled about is the workings of interline spacing and why ocassionaly (depending on font sizes and leading) some lines appear to crowd together. While putting together examples to test my understanding, I encountered something unexpected.

Eijkhout writes:

TEX tries to keep a certain distance between the reference points of boxes that are added to a vertical list; in particular it tries to keep the baselines of ordinary text at a constant distance, the \baselineskip. Actually, the \baselineskip is a glue, so line distances can stretch or shrink. However, the natural sizes, as well as the stretch and the shrink, are the same between all lines. <...> if this [distance would make] <...> the two boxes [...] too close together [less then \lineskiplimit], TEX inserts the \lineskip glue instead.

- "TeX By Topic", p. 155. "Interline glue"

Fine, as long as distances to get too small, interline space is fixed and consists of glue which can stretch as needed. But than, why doesn't it?

\documentclass[12pt]{article}

\usepackage[paperwidth=6in,paperheight=6in,textwidth=4in]{geometry}
\usepackage{lmodern}
\baselineskip=12pt
\usepackage[OT1]{fontenc}

\begin{document}
{
\vbox {
\hrule
\vfil
\hbox{
\vbox to 4in {
\input tufte
}
}
\vfil
\hrule
}
}
\end{document}


If interline glue can stretch and shrink, why doesn't the spacing grow to fill the vbox? Instead, XeTeX complains of an underfull vbox.

By default, set in /tex/plain/base/plain.tex (or latex.ltx), the glue value is set (equivalently) to \baselineskip=12pt. i.e. it has no stretch or shrink, the same goes for \lineskip=1pt.

So, with the defaults, intra-baseline distances can't flex in the way described. Spacing can look uneven if the boxes get too close together and \lineskiplimit is violated, in which case the distance between the boxes (as opposed to between the baselines) is constant. Visually that looks like uneven spacing when different lines have or lack ascender/descenders. In any case, with the default values for the interline parameters, it's always Either:

• The baseline distance equals \baselineskip -OR-
• The vertical space two boxes (measured from the bottom of one to top of next) is equal to \lineskip.

i.e. there's no arbitrary stretching to fill up boxes.

You can redefine \baselineskip to have some stretch in which case the example in the OP works as expected, and the vbox is filled. Here are some examples showing how interline glue operates, the last example shows the result of manually setting \baselineskip with some stretch to it.

\documentclass[12pt]{article}

\usepackage[paperwidth=6in,paperheight=5in,textheight=4.5in,textwidth=4in,top=0.1in]{geometry}
\usepackage{fontspec}
\usepackage{lmodern}

\parindent=0.1in
\parskip=0pt

\def\example{
\bigskip
\noindent{\bf Example:}
\medskip\par
}

\def\verb#1{{\char\\#1}}

\pagestyle{empty}
\begin{document}

Force all interline distances to adhere to \verb{lineskip}. Set at 0pt, the bottom
of the upper line is at the same height as the topmost point of the line below.
See for example the way the f'' in information" on line 1 touches the
d" in and" in line 2.

Visually, the text appears to have some lines crowded" together
while others are separated, but in fact it is simply that the inter-box
distance which is kept constant instead of the intra-baseline distance.

\smallskip

{
\baselineskip=12pt
\lineskiplimit=10000pt
\lineskip=0pt
\example
{
\hrule
\vbox{ % Make the box explicit
{\fontencoding{OT1}\selectfont
\input tufte
}
}
\hrule
}
}
\vfil
\break

Set text inside a sized vbox and Disable \verb{lineskiplimit}.
All intra-baseline distances are equal to \verb{baselineskip}, and overlap is possible.
The \verb{vbox} size has no effect on line spacing because, as by default values,
he glue has no "flex" to it.

{
\baselineskip=5pt
\lineskiplimit=-100pt  % Note: setting this to -1000pt triggers a bug in pdftex?
\lineskip=1pt

\example
\vbox {
\hrule
\vfil
\hbox{
\vbox to 2.5in{
{\fontencoding{OT1}\selectfont
\input tufte
}
}
}
\vfil
\hrule
}
}
\vfil
\break

%

As in the previous example, set text inside a sized vbox and Disable \verb{lineskiplimit}.
All intra-baseline distances are equal to \verb{baselineskip}, and overlap is possible.
This time, we give a {\tiny \itshape tiny}\/ amount of stretch to the \verb{baselineskip}, which
grows as necessary to fill the vbox.

\example
{
\baselineskip=12pt plus 0.001pt
\lineskiplimit=1pt
\lineskip=0pt plus 0.01pt

\vbox {
\hrule
\vfil
\hbox{
\vbox to 2.5in {
{\fontencoding{OT1}\selectfont
\input tufte
}
}
}
\vfil
\hrule
}
}
\end{document}
`