[Tex/LaTex] Applications of various strength of \linebreak command

line-breaking

This is a curiosity-driven question.

The LaTeX \linebreak command comes with five options, from 0 to 4, determining its strength. \linebreak[0] allows TeX to break a line where he normally does not do it, while \linebreak[4] forces him to break a line in a place where the command is put (and is thus equivalent to \linebreak).

To be honest, in my LaTeX practice never have I used any variation of the command beyond mere \linebreak. So, I would like to ask you to share your experience with applying other possibilities. To be more precise:

  • could you please point to situations in which it is reasonable to apply \linebreak[i], where i is not 4 ? could you please explain why you do so ?
  • maybe some of you worked out some general rules which facilitate typesetting with LaTeX (similar for example to placing non-breakable space joining single letter with a word that follows it, like in: a~dog) ?

This, I think, qualifies as a CW question, yet I do not have enough reputation to create it.

Best Answer

The whole TeX linebreaking mechanism is driven by minimising badness (demerits, which are penalties squared, more or less) over the paragraph. So at one level it is natural to be able to inject penalties of different strengths so that for example you can emulate the behaviour in math where a linebreak can happen at a relation with penalty by default 500 (\relpenalty) or an operator with penalty by default 700 (\binoppenalty).

However as egreg commented on the question, use of \linebreak at all should be fairly rare anyway and if you get as far as wanting manual control you tend to want to force a break. Also the values in the standard classes are a little odd:

   0
   51 (`\@lowpenalty`)
  151 (`\@medpenalty`)
  301 (`\@highpenalty`)
10000

these are not exactly evenly distributed over the range (10000 is the maximum value) especially when the demerits formula squares these values.

This means that while \linebreak[0] is useful to allow a break at a place where a break wouldn't normally be allowed and \linebreak[4] is useful to force a break. and \linebreak[1 or 2 or 3] are very occasionally useful as a hint. It is really hard to find any general cases where there can be any real advance logic in choosing which of 1 2 or 3 to use, although obviously it is easy to generate test cases where they act differently, all three are considerably weaker penalties than the penalties on math operators, and a bit higher than the penalty for breaking at hyphenation. (50 is the default penalty for breaking at a hyphen).

In the above I've not really distinguished between \linebreak and \nolinebreak (the only difference being the sign of the penalty added) the contribution (positive or negative) to the overall demerits calculation for the paragraph has the same issues in either case.

Related Question