Suppose I type

\hbox to \hsize{abc}



Now, since the first \hbox is set at \hsize, I am expecting the abc to be glued with maximum stretched glue. In the second \hbox, I expect abc to be glued with normal glue width without any stretching and shrinking. However, when I compare the results in TeX, it seemed that both produce the same results, why?

  • The first one creates the underful hbox of doom. Also try \hbox to \hsize{abc def}. May 2 '16 at 16:12
  • 2
    Keep in mind that glue is applied between words, not between letters of a word (that is kerning which is not allowed to shrink or stretch). May 2 '16 at 16:13
  • @HenriMenke This is the answer, thank you! Can you post it as an answer please?
    – Kun
    May 2 '16 at 16:20
  • There should be glue to begin with. ;-)
    – egreg
    May 2 '16 at 16:46

Concerning the line

\hbox to \hsize{abc}

you are actually right in your statement

I am expecting the abc to be glued with maximum stretched glue

Unfortunately, you can't see the glue, because glue is applied between words, not between letters of a word. The space between the letters is given by the font settings, namely kerning which is not allowed to shrink or stretch.

You can easily make the inserted glue visible by simply using two words, where the second one is pushed to far right (due to the glue stretchability).

\hbox to \hsize{abc def}

enter image description here

  • Just a side question, I have seem many times on this site people typeset the output with this yellow pinkish stripe, how can I do that too?
    – Kun
    May 2 '16 at 17:33
  • @Kun when in doubt, click "edit" just to have a peek -- that is a quotation box :)
    – Quentin
    May 2 '16 at 19:08

The term “glue” might be misleading. It is not something that's used to glue letters together, which isn't needed, but rather something that spaces things from one another.

Glue can be rigid or flexible; flexibility can be in the amount of allowed stretch or shrink (or both, of course). When TeX is ordered to fill with text some amount of horizontal space, it takes all available flexible glue into consideration. Before stretching or shrinking, it computes the natural width of the material, in order to decide whether it's wider or narrower than the size to be filled up; then it looks at the flexible glue and divides the stretch or shrink based on the amount of flexibility.

Here's a list of related topics:

Note that shrinking will never be more than the available amount, whereas TeX is allowed to stretch more than is stated as “optimal” (at the expense of badness). Infinite stretchability or shrinkability take the precedence and won't never produce bad boxes (bad to TeX, of course, in the sense of its algorithms; the result might appear awful to a human reader nonetheless).

Spaces in the input are instructions to TeX to insert glue (shrinkable and stretchable). So

\hbox to \hsize{abc def}

will stretch the contents at the space (with an “underfull \hbox” message). If you want to stretch the space between the letters, you have to insert glue manually:

\hbox to\hsize{a\hfil b\hfil c}

will space out the three letters (with no message, because we used infinite glue).

  • 1
    On page 70, below exercise 12.1, Knuth even mentions that the name “glue” was a bad decision. May 3 '16 at 7:13

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.