\def\usrf{\leavevmode\leaders\hrule\hskip 0pt plus 1em minus 0pt\kern 0sp}
\noindent A\usrf{}B C\linebreak DEFGH

results in that compilation result

where the "underscore" between A and B is way longer than 1em. How can I limit the maximum length of the \hrule, and why does it not work with the glue "stretchability" as given?

  • 2
    As soon as you assign nonzero stretchability to a glue, it will stretch without limit (at the expense of badness). Just like the space between B and C is stretching quite wide.
    – egreg
    Dec 24, 2015 at 17:46
  • Now that you say it... So much for the explanation what is going on (+1). Now I need something "stretchable between length x and length y". Does something like that exist?
    – Stephen
    Dec 24, 2015 at 17:53

1 Answer 1


You are telling TeX to stretch a line to the line width, so it will obey your order.

Let's see a simpler example (plain TeX):

\hbox to\hsize{A\leaders\hrule\hskip 0pt plus 1em minus 0pt B C}



You get

enter image description here

The value printed by \the\badness is the badness of the last typeset box. Indeed, the terminal will also show

Underfull \hbox (badness 10000) detected at line 1
\tenrm A B C

As soon as a glue has nonzero stretchability, it will stretch as much as required, at the expense of badness. Just like it happens to the glue between B and C.

If you change the first line to

\setbox0=\hbox to\hsize{A\leaders\hrule\hskip 0pt plus 1em minus 0pt B C}

you'll find, in the log file,

\hbox(6.83331+0.0)x469.75499, glue set 38.11542
.\tenrm A
.\leaders 0.0 plus 10.00002
.\tenrm B
.\glue 3.33333 plus 1.66498 minus 1.11221
.\tenrm C

so the glue stretch ratio is 38.11542; this means that the first glob of glue (from \leaders) will become

38.11542 * 10.00002 = 381.15496

point wide and the second glob will become

38.11542 * 1.66498 = 63.46141

point wide.

Can I state “stretch at most X”? No, because of the rule above. With some computations it is of course possible.

You must log in to answer this question.

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