7

The question concerns The TeXbook, page 78, 4th dangerous-bend paragraph.

For example, let's suppose that \baselineskip=12pt plus 2pt, \lineskip=3pt minus 1pt, and \lineskiplimit=2pt... Suppose further that a box whose depth is 3pt was most recently added to the current vertical list; we are about to add a new box whose height is h. If h = 5pt, the interline glue will be 4pt plus 2pt, since this will make the baselines 12pt plus 2pt apart when we add h and the previous depth to the interline glue. But if h = 8pt, the interline glue will be 3pt minus 1pt, since \lineskip will be chosen in order to keep from violating the given \lineskiplimit when stretching and shrinking are ignored.

At the end of this paragraph it is said that stretching and shrinking are ignored in that example. But how would the answer change, if they weren't ignored?

Are the following considerations correct?

8+3=11pt

this is less than \lineskiplimit apart from the edges, but using stretching component of \baselineskip (plus 2pt) \lineskiplimit is not exceeded, because

12+2 = 14-(8+3) = 3 > \lineskiplimit

so glue 1pt plus 2pt must be used.

  • 2
    The resolution of the vertical stretch and shrink components are done after the paragraph is set. Since the exact values of these components are not known, when TeX breaks a paragraph into lines, they cannot be used in the comparison. The distance of the previous box to the following box is therefore compared with \lineskiplimit without taking the stretch and shrink components of \baselineskip into account. – Heiko Oberdiek Aug 19 '15 at 10:42
  • 1
    BTW, please, improve the question by making it self-contained, without the need to look for the settings in the TeXbook or finding the values in its source file texbook.tex. Also the math is quite fuzzy. – Heiko Oberdiek Aug 19 '15 at 10:44
  • @HeikoOberdiek Is there a way to trace the final glue settings (i.e., how to make TeX print 3pt minus 1pt in this case)? – Igor Liferenko Aug 19 '15 at 11:38
  • You would have a circular dependency, the final vertical glue setting depends on the interline spaces. If I have you understood correctly, you want to make the interline spaces dependent on the final glue settings? – Heiko Oberdiek Aug 19 '15 at 11:42
  • @HeikoOberdiek I just want to see the exact values that TeX is choosing. Using \showbox does not help, because it shows general glue, not exact values (e.g., \glue 0.0 plus 1.0fil minus 1.0fil) – Igor Liferenko Aug 19 '15 at 11:45
4

Consider the following example:

\showboxdepth=\maxdimen \showboxbreadth=\maxdimen \tracingonline=1

\baselineskip=12pt plus 2pt
\lineskip=3pt minus 1pt
\lineskiplimit=2pt

\setbox0=\vbox{
  \hbox{\vrule height 5pt depth 3pt} % this has depth 3pt
  \hbox{\vrule height 5pt} % this has height 5pt
}
\showbox0

\setbox0=\vbox{
  \hbox{\vrule height 5pt depth 3pt} % this has depth 3pt
  \hbox{\vrule height 8pt} % this has height 8pt
}
\showbox0

\bye

The output on the terminal is

> \box0=
\vbox(17.0+0.0)x0.4
.\hbox(5.0+3.0)x0.4
..\rule(5.0+3.0)x0.4
.\glue(\baselineskip) 4.0 plus 2.0
.\hbox(5.0+0.0)x0.4
..\rule(5.0+*)x0.4

! OK.
l.11 \showbox0

? 
> \box0=
\vbox(19.0+0.0)x0.4
.\hbox(5.0+3.0)x0.4
..\rule(5.0+3.0)x0.4
.\glue(\lineskip) 3.0 minus 1.0
.\hbox(8.0+0.0)x0.4
..\rule(8.0+*)x0.4

! OK.
l.17 \showbox0

? 

that reflects what's said in your quotation from the TeXbook.

Now, let's modify the example as

\showboxdepth=\maxdimen \showboxbreadth=\maxdimen \tracingonline=1

\baselineskip=12pt plus 2pt
\lineskip=3pt minus 1pt
\lineskiplimit=2pt

\setbox0=\vbox spread 2pt{
  \hbox{\vrule height 5pt depth 3pt} % this has depth 3pt
  \hbox{\vrule height 5pt} % this has height 5pt
}
\showbox0

\setbox0=\vbox spread 2pt{
  \hbox{\vrule height 5pt depth 3pt} % this has depth 3pt
  \hbox{\vrule height 8pt} % this has height 8pt
}
\showbox0

\bye

Now the output on the terminal is

> \box0=
\vbox(19.0+0.0)x0.4, glue set 1.0
.\hbox(5.0+3.0)x0.4
..\rule(5.0+3.0)x0.4
.\glue(\baselineskip) 4.0 plus 2.0
.\hbox(5.0+0.0)x0.4
..\rule(5.0+*)x0.4

! OK.
l.11 \showbox0

? 

Underfull \vbox (badness 10000) detected at line 16

\vbox(21.0+0.0)x0.4
.\hbox(5.0+3.0)x0.4
..\rule(5.0+3.0)x0.4
.\glue(\lineskip) 3.0 minus 1.0
.\hbox(8.0+0.0)x0.4
..\rule(8.0+*)x0.4

> \box0=
\vbox(21.0+0.0)x0.4
.\hbox(5.0+3.0)x0.4
..\rule(5.0+3.0)x0.4
.\glue(\lineskip) 3.0 minus 1.0
.\hbox(8.0+0.0)x0.4
..\rule(8.0+*)x0.4

! OK.
l.17 \showbox0

? 

The first box has enough stretching for being filled up, whereas the second box hasn't.

Conversely, if we change spread 2pt into spread -1pt, the output on the terminal will be

Overfull \vbox (1.0pt too high) detected at line 10

\vbox(16.0+0.0)x0.4
.\hbox(5.0+3.0)x0.4
..\rule(5.0+3.0)x0.4
.\glue(\baselineskip) 4.0 plus 2.0
.\hbox(5.0+0.0)x0.4
..\rule(5.0+*)x0.4

> \box0=
\vbox(16.0+0.0)x0.4
.\hbox(5.0+3.0)x0.4
..\rule(5.0+3.0)x0.4
.\glue(\baselineskip) 4.0 plus 2.0
.\hbox(5.0+0.0)x0.4
..\rule(5.0+*)x0.4

! OK.
l.11 \showbox0

? 
> \box0=
\vbox(18.0+0.0)x0.4, glue set - 1.0
.\hbox(5.0+3.0)x0.4
..\rule(5.0+3.0)x0.4
.\glue(\lineskip) 3.0 minus 1.0
.\hbox(8.0+0.0)x0.4
..\rule(8.0+*)x0.4

! OK.
l.17 \showbox0

? 

The first box is overfull by 1pt, because there's no shrinkability; on the other hand, the second box is good, because it has shrinkability.

As you can see, the .\glue(\baselineskip) and \glue(\lineskip) lines are the same in all three cases.

What “when stretching and shrinking are ignored” means is that the computations of the interline glue are performed by taking into account only the natural size of \baselineskip; if \lineskiplimit is not exceeded, the \baselineskip is inserted with suitably reduced natural size and with the stated plus and minus components; otherwise the \lineskip glue is inserted, with its plus and minus components. The stretchability and shrinkability will act when the vertical list being constructed (typically, but not necessarily, a paragraph) is packed in a vertical box (typically for shipping out a page).

Thus the computation of glue in the first box is: 12 - 3 - 5 = 4 > \lineskiplimit, so the baseline skip glue is set to 4pt plus 2pt; in the second box we have 12 - 3 - 8 = 1 < \lineskiplimit, so \lineskip is used. The stretchability and shrinkability of \baselineskip play no role in this computation: TeX has no way of knowing whether the box which the current vertical list will end up in will need to stretch or shrink glue.

  • BTW, the ...+* notation does not seem to be explained in The TeXbook. Why simply 0 is not used here instead of *? – Igor Liferenko Aug 23 '15 at 6:13
  • Just a notice about how to get exact values of glue from the trace: it shows glue set ratio glue set R[fil...]. If there is no sign, it means stretch glue is modified, if there is minus, then shrink glue is modified; so to get the exact values for each glob of glue, take current natural glue and, when its stretch/shrink component has the same order of infinity as in glue set ratio, add it R times ([fil...] in glue set ratio denotes the order of infinity affected). E.g., in the last trace here we get: 3+1*(-1), so the glue ultimately becomes 2pt. – Igor Liferenko Aug 23 '15 at 6:28
  • @IgorLiferenko Every available stretch/shrink component is multiplied by the glue set ratio. – egreg Aug 23 '15 at 8:40
  • AFAIK, there can't be glue set ratio with plus and minus signs simultaneously, either plus or minus sign is used, which determines which one of the components of every glob of glue we must take into account. – Igor Liferenko Aug 23 '15 at 9:18
  • @IgorLiferenko glue set x and glue set - x mean, respectively, that the glue must stretch or shrink. The available plus components are used in the former case, the minus components in the latter. – egreg Aug 23 '15 at 9:26

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.