[texhax] Isthis a bug in LaTex?

Ian Collier imc at comlab.ox.ac.uk
Thu Sep 18 19:00:24 CEST 2003

rsherry8 at comcast.net ("Robert Sherry") writes:
>        \flushleft
>        I claim that a graph G can not have a poor subgraph with only one
>        or two vertices but it can have a poor subgraph
>        with only three vertices. If G is a graph with exactly
>        three vertices and it has a poor subgraph then I claim G is complete.
>        \newline
>        \newline

>The problem is the output has a separate line for the words "graph with". I
>do not
>understand why? Have I found a bug?

Firstly, flushleft is supposed to be an environment rather than a
command, but that's a minor issue.  The equivalent which can be used
as a command is \raggedright, but it doesn't do a terrific job for
reasons explained here:
This page suggests a package called ragged2e which does the job properly.

Secondly, \newline probably isn't what you want - it's probably better
to use \\[1ex] or something similar to add the appropriate amount of
vertical space.

Finally, what is happening in the above example is this: the \flushleft
command sets TeX's `\rightskip' register to an infinitely-stretchable
amount of glue.  Basically, what this tells TeX is that it doesn't
matter how long or short a line of text is (as long as it doesn't
extend beyond the right-hand margin), and so TeX will sometimes feel
free to put a very short line in the middle of the paragraph.  With
the two newlines, what you effectively have is a paragraph followed by
\break\break\par and for some reason this causes TeX to select "graph
with" as a short line rather than breaking after "claim" as it otherwise

**Question for TeX Grandmasters**
Using TeX 3.14159 and ending the file with \break\break (instead of
\newline\newline) I'm getting this (edited output):

@@48: line 2.2 t=200 -> @@19
graph with
@@51: line 3.2 t=300 -> @@48
exactly...I claim 
@@71: line 3.2 t=300 -> @@48
@@72: line 3.3 t=2801 -> @@44
G is com-plete.
@@79: line 4.2 t=400 -> @@71
@@80: line 4.3 t=1200 -> @@51
@\penalty via @@51 b=62 p=-10000 d=5184
@\penalty via @@71 b=0 p=-10000 d=100
@@81: line 4.2 t=400 -> @@71
@@82: line 4.3 t=5484 -> @@51
@\penalty via @@82 b=10000 p=-10000 d=*
@@83: line 5.0 t=5484 -> @@82
@\par via @@83 b=0 p=-10000 d=*
@@84: line 6.2- t=5484 -> @@83

I question (a) why b=10000 on that penultimate break, given that
\rightskip has infinite stretchability, and (b) why the break has
to be via @@82 rather than @@81 when on the face of it @@81 would
seem to give fewer demerits.

Note that if I add a printing character (say, `x') after the second
\break then we get, as expected*:

@@81: line 4.2 t=400 -> @@71
@@82: line 4.3 t=5484 -> @@51
@\penalty via @@81 b=0 p=-10000 d=100
@\penalty via @@82 b=0 p=-10000 d=100
@@83: line 5.2 t=500 -> @@81
@\par via @@83 b=0 p=-10000 d=*
@@84: line 6.2- t=500 -> @@83

But how did the `x' affect the badness of the _previous_ line? 
It seems to be something trigged only by something of the form:
\break\break\hfil (the \hfil is of course supplied by \parfillskip when
the `x' is not present).  Either I am confused or this is a subtle
bug in TeX.
* (this involves setting \pretolerance=-10 to force a second pass)
---- Ian Collier : imc at comlab.ox.ac.uk : WWW page below
------ http://users.comlab.ox.ac.uk/ian.collier/imc.shtml

More information about the texhax mailing list