Consider the following minimal, using \linebreak
:
\documentclass{article}
\begin{document}
It is impossible to say how first the idea entered
my brain, but, once conceived, it haunted me day
and night. \linebreak
Object there was none.
\tt\meaning\linebreak
\end{document}
This produces the output,
I am interested to find out how the explanation of this behaviour. Is LaTeX2e buggy in this respect?
Edit
Based on the suggestions in the answers, I had another look at the TeXBook and it appears the behaviour is embedded in TeX's algorithm, quoting:
Question In one of the paragraphs earlier in this chapter, the author used
\break
to force a line break in a specific place; as a result, the third line of that particular paragraph was really spaced out. Explain why all the extra space went into the third line, instead of being distributed impartially among the first three lines.answer Distributing the extra space evenly would lead to three lines of the maximum badness (10000). It's better to have just one bad line instead of three, since TeX doesn't distinguish degrees of badness when lines are really awful. In this particular case the
\tolerance
was 200, so TeX didn't try any line breaks that would stretch the first two lines; but even if the tolerance had been raised to 10000, the optimum setting would have had only one underfull line. If you really want to spread the space evenly you can do so by using\spaceskip
to increase the amount of stretchability between words.
Of course I was wrong in titling the question a failing
and apologies to the LaTeX Team and Knuth. However, I still have a feeling that the algorithm has room for improvement in this edge cases or at least \linebreak
could be given a better semantic name \maybebreak
can be one of them.
\newline
instead. We don't have a\linebreak
vs.\newline
question yet, it seems, but the difference is similar to the one of\pagebreak
vs\newpage
.source2e
and experimenting. There is a comment on the analogy between\pagebreak
andnewpage
as well as a note that it is still considered buggy.\linebreak
is usually considered a "last resort" command, to be used when nothing else (not even\newline
) will easily cause a line to break in a desired place in the middle of a paragraph and it's required to keep an even right margin.