3

I'm playing a bit with TeX's leaders and ran into a problem I don't understand. Given the following example code:

\documentclass{article}

\begin{document}

\def\bul{%
    \begingroup
    \setbox0=\hbox to 10pt{\hss\textbullet\hss}%
    \skip0=\wd0 plus 0.5\wd0 minus 0.5\wd0
%    \skip0=10pt plus 5pt minus 5pt  % the same as above
    \cleaders\box0\hskip\skip0
    \endgroup
}

1: \fbox{\hbox to 30pt{\null\hskip13pt\bul\hskip13pt\null}}  okay, too few space

2: \fbox{\hbox to 30pt{\null\hskip10pt\bul\hskip10pt\null}}  okay, space fits exactly

3: \fbox{\hbox to 30pt{\null\hskip7.5pt\bul\hskip7.5pt\null}}  okay, maximum stretch
\medskip

4: \fbox{\hbox to 30pt{\null\hskip11pt\bul\hskip11pt\null}}  wrong, still enough space left

5: \fbox{\hbox to 30pt{\null\bul\null}} wrong, too many bullets

\end{document}

\bul should, as I understand, output at most one \textbullet centered across the available space if there's some free horizontal space of 5pt up to 15pt. Here's the result:

enter image description here

On the first line there's only 4pt left, so no bullet occurs. On line 2 the bullet can take its natural width and fits exactly once. On the third line it needs to stretch to its maximum width. Those cases are fine. The ones I don't understand are on the next two lines.

Line 4 should leave a space of 8pt in which a bullet can fit quite comfortably. No bullet occurs, though. Why?

The opposite problem is on line 5. Here the maximum stretch is exceeded, hence TeX gives an underfull \hbox warning. But why does it output three boxes?

Section 9.3.3 of TeX by Topic explicitly states that you should use \copy with the various leaders commands to make sure the box register is not empty after it has been used first. Actually, this is exactly the effect I want to achieve, which is why I used \box. The output still has three bullets.

Could anyone explain why that is happening (and also how to fix it)?

1 Answer 1

2

Glue with a nonzero stretch component will stretch to fill anyway, at the expense of badness.

In the fifth example, with \showoutput, you'd see

...\hbox(4.44444+0.0)x30.0, glue set 4.0
....\hbox(0.0+0.0)x0.0
....\cleaders 10.0 plus 5.0 minus 5.0
.....\hbox(4.44444+0.0)x10.0, glue set 2.5fil
......\glue 0.0 plus 1.0fil minus 1.0fil
......\mathon
......\tensy ^^O
......\mathoff
......\glue 0.0 plus 1.0fil minus 1.0fil
....\hbox(0.0+0.0)x0.0

where the glue stretch factor is 4. Hence the glue counts for 10+4*5=30 pt. No fix, this is how it is supposed to work.

Note: \tensy is because I typeset the thing with plain TeX to avoid irrelevant parts to show up.

With your document, the relevant diagnostic would be

..........\hbox(4.44444+0.0)x30.0, glue set 4.0
...........\hbox(0.0+0.0)x0.0
...........\cleaders 10.0 plus 5.0 minus 5.0
............\hbox(4.44444+0.0)x10.0, glue set 2.5fil
.............\glue 0.0 plus 1.0fil minus 1.0fil
.............\OMS/cmsy/m/n/10 ^^O
.............\glue 0.0 plus 1.0fil minus 1.0fil
...........\hbox(0.0+0.0)x0.0
5
  • When you write "No fix", do you also mean there's no way to define the desired \bul macro? Also, any ideas about line 4?
    – siracusa
    Mar 11, 2019 at 9:41
  • @siracusa In line 4 the space for the leaders is 8pt, which is less than the natural width of the leader box, so nothing shows up.
    – egreg
    Mar 11, 2019 at 11:33
  • @siracusa If you want glue that stretches, but not more than a stated amount, well, you can't.
    – egreg
    Mar 11, 2019 at 11:56
  • I'd be fine with glue that stretches more than the maximum amount, but I don't want the bullet to occur multiple times in that case
    – siracusa
    Mar 11, 2019 at 14:43
  • @siracusa You're out of luck, I'm afraid.
    – egreg
    Mar 11, 2019 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .