# How does TeX break paragraphs into lines when there is only two element in a pararaph?

Suppose we have the following code:

\def\tp#1#2{#1\hskip 300cm minus 300cm\hbox{#2}}
\tp{Hello}{World it is}


and

\def\tp#1#2{#1\hskip 300cm \hbox{#2}}
\tp{Hello}{World it is}


The first one gives us while in the second one, the box World it is has gone off the board. My question is:

Why wouldn't TeX break the paragraph into two lines rather than one line in both of the above cases? For example, in the first case, naturally I thought TeX would break the World it is part to the second line since the normal width of the glue is much larger than the page width. I understand that the glue came with a shrinking capability in the first case, which added fuss to this question; so in the second case I deleted this capability, and the second part of the text went of the board rather than starting on a new line to my surprise. Why?

EDIT The following is interesting to note:

\def\tp#1#2{#1\hskip 400cm minus 400cm\penalty 1\hbox{#2}}
\tp{Hi}{World it is}
\def\tp#1#2{#1\hskip 400cm minus 400cm\penalty 10\hbox{#2}}
\tp{Hi}{World it is}


The first set shifted the second part to a new line while the second fitted everything in one line.

For example, in the first case, naturally I thought TeX would break the World it is part to the second line since the normal width of the glue is much larger than the page width.

Since the glue has no stretch or shrink component 300cm is not the "normal width" it is its fixed width.

the only break point in

#1\hskip 300cm \hbox{#2}


is before the skip (as #1 is the unbreakable Hello and anyway the first word of a paragraph does not break).

If it broke here the glue would be discarded at the beginning of the next line so the first line would just have an indentation box, Hello and \rightskip glue (which is 0pt) as such it would be massively underfull and so this is not a feasible breakpoint.

In the version with minus 300cm no break point needs to be taken as it can all be shrunk on to one line.

• Can you expand on the discussion of normal and fixed width a little bit? Or point to some references. Thanks!
– Kun
May 5, 2016 at 14:02
• @Kun I'm not sure what there is to say, \hskip 300cm is a skip of 300cm, but \hskip 300cm minus 300cm is a skip with normal (natural) width 300cm but may shrink to 0cm. May 5, 2016 at 14:15
• You said the only break point is before the skip, but is it possible that it breaks after 400cm minus 400 (refer ingto my edit)? Furthermore, I tried adding spaces after the glue but TeX seems still unwilling to break after the glue before the second part.
– Kun
May 5, 2016 at 14:50
• @Kun no there is no breakpoint after a skip. (That is the difference with your edited example that adds a \penalty as that adds an additional breakpoint May 5, 2016 at 14:56
• @Kun it is exactly the same, if tex breaks at the glue between words, the break always happens before the glue and the glue is discarded (so you do not get space at the start of the next line) so the items before the break have to fill the line without using that glue. It is a breakpoint but not feasible as the first line would be infinitely underfull (>10000 badness) May 5, 2016 at 15:57

The horizontal skip sticks to the next thing because there is no way for TeX to break the line here. There is no space following the skip because any space here is consumed by the processing.

If you take #2 out of the \hbox, you'll see that only the first word disappears and the rest goes to the next line because now you have a space allowing a line break.

Likewise, if you change 300cm to 0cm, you'll see that HelloWorld ... is typeset and not Hello World ....

\def\tp#1#2{#1\hskip 300cm minus 300cm\hbox{#2}}
\tp{Hello}{World it is}

\def\tp#1#2{#1\hskip 300cm \hbox{#2}}
\tp{Hello}{World it is}

\def\tp#1#2{#1\hskip 300cm #2}
\tp{Hello}{World it is}

\def\tp#1#2{#1\hskip 0cm \hbox{#2}}
\tp{Hello}{World it is}
\bye


# EDIT

If you add something like \showlists and adapt the text slightly

\def\tp#1#2{#1\hskip 300cm minus 300cm\hbox{#2}}
\showlists
\tp{Hi}{World it is}

\def\tp#1#2{#1\hskip 300cm \hbox{#2}}
\showlists
\tp{He}{World it is}

\def\tp#1#2{#1\hskip 0cm \hbox{#2}}
\showlists
\tp{Ho}{World it is}
\showlists

\bye


[I'm not sure you need to keep saying \showlists if you don't want the compilation to stop.]

you can get a better idea what's happening:

### vertical mode entered at line 0
prevdepth ignored

! OK.
l.8 \showlists

?

### vertical mode entered at line 0
### current page:
\glue(\topskip) 3.05556
\hbox(6.94444+0.0)x469.75499, glue set - 0.954
.\hbox(0.0+0.0)x20.0
.\tenrm H
.\tenrm i
.\glue 8535.82677 minus 8535.82677
.\hbox(6.94444+0.0)x46.75008
..\tenrm W
..\kern-0.83334
..\tenrm o
..\tenrm r
..\tenrm l
..etc.
.etc.
total height 10.0
goal height 643.20255
prevdepth 0.0, prevgraf 1 line

! OK.
l.12 \showlists

?

Overfull \hbox (8144.76631pt too wide) in paragraph at lines 13--14
[]\tenrm He [] |

\hbox(6.94444+0.0)x469.75499
.\hbox(0.0+0.0)x20.0
.\tenrm H
.\tenrm e
.\glue 8535.82677
.\hbox(6.94444+0.0)x46.75008
..\tenrm W
..\kern-0.83334
..\tenrm o
..\tenrm r
..\tenrm l
..etc.
.etc.

### vertical mode entered at line 0
### current page:
\glue(\topskip) 3.05556
\hbox(6.94444+0.0)x469.75499, glue set - 0.954
.\hbox(0.0+0.0)x20.0
.\tenrm H
.\tenrm i
.\glue 8535.82677 minus 8535.82677
.\hbox(6.94444+0.0)x46.75008
..\tenrm W
..\kern-0.83334
..\tenrm o
..\tenrm r
..\tenrm l
..etc.
.etc.
\glue(\parskip) 0.0 plus 1.0
\glue(\baselineskip) 5.05556
\hbox(6.94444+0.0)x469.75499
.\hbox(0.0+0.0)x20.0
.\tenrm H
.\tenrm e
.\glue 8535.82677
.\hbox(6.94444+0.0)x46.75008
..\tenrm W
..\kern-0.83334
..\tenrm o
..\tenrm r
..\tenrm l
..etc.
.etc.
total height 22.0 plus 1.0
goal height 643.20255
prevdepth 0.0, prevgraf 1 line

! OK.
l.16 \showlists


For the last case (which I isolated by removing the others), I get

### horizontal mode entered at line 8
\hbox(0.0+0.0)x20.0
\tenrm H
\tenrm o
\glue 0.0
\hbox(6.94444+0.0)x46.75008
.\tenrm W
.\kern-0.83334
.\tenrm o
.\tenrm r
.\tenrm l
.etc.
etc.
spacefactor 1000
### vertical mode entered at line 0
prevdepth ignored


I think that it does not treat HoWorld as a single world. It is that the \hskip eats up any following glue, including an interword space. A space between words is, after all, just glue. But I'm by no means sure of this.

• thank you for taking time explaining this to me. Yes, I tried your suggestion. So does it mean TeX cannot break line at the glue or is TeX treating Hello\hskip 300cm minus 300cm\hbox{World it is} as a single word, if so, I thought only \kern can produce extra spaces in a single word?
– Kun
May 5, 2016 at 1:02
• I think using \hskip will allow breakpoint, see tex.stackexchange.com/a/112299/64955. I know the post I linked discussed in a LaTeX specific fashion, but the principle should still apply.
– Kun
May 5, 2016 at 1:12
• @Kun \showlists might help? See edit above, although I don't completely understand the output.
– cfr
May 5, 2016 at 2:52
• Bear in mind that the question you linked is primarily focused on maths mode. Not all of it is specific to maths mode, but it is worth bearing in mind. Your cases are in horizontal mode - not maths mode - so some things will be different. (But not the basics, I don't think, about kerns and glue, though I'm not certain.)
– cfr
May 5, 2016 at 2:58
• @Kun the glue does not shrink at all in the cases where you have not specified a minus component, so TeX does not need to consider the badness of glue shrinking in those cases. May 5, 2016 at 14:21