While attempting to answer this question, I re-read Chapter 14 of The TeX Book (on how TeX breaks paragraphs into lines). It got me thinking: Is there a way to restrict the length of a string of text while still allowing that text to be broken across lines? For example, let's say I want to typeset "Lorem Ipsum Dolor" and I want it to be exactly 3cm in length. I could do \hbox to 3cm{Lorem Ipsum Dolor}
(with an optional \hfill
at the end if I just want to pad the extra length with whitespace). The problem with that is that the \hbox
will not be broken across lines. Is there a way to do something similar while allowing for line breaks? In other words, I would be okay with "Lorem Ipsum" being at the end of one line and "Dolor" being at the begging of the next, as long as their total length equals 3cm.
Edit: I don't think I was very clear about for what I'm looking. Consider the line "Ut fermentum pharetra lacus, id ornare dolor pretium tempor" in this example:
In this example, that sentence was broken over two lines. I want to be able to explicitly set the total length of the "Ut fermentum..." sentence, regardless of how it is broken across lines. In this example, I might want the sum of the lengths of s_1 and s_2 to be equal to, say, 5in. This could be accomplished by adding glue between words or padding the end with glue. This is easy to do if we know that there will be no line breaks in the string; we can then use either \hbox spread 5in{}
or \hbox to 5in{}
. The problem occurs when a line break does occur in the string, since the \hbox
method would likely force the string to be on a single line. Furthermore, if the natural length of the string is greater than \textwidth
, then the \hbox
would overfill.