There is a more or less equivalent question to this: Ensure minimal length of last line, but I absolutely need a TeX solution. I more or less stumbled upon the problem mentioned in the discussion of egreg's answer, and I'd like to see a deeper analysis just to make sure there absolutely is no working TeX solution.
Replicating Patrick's solution (insert unbrekable space between words at the end) in TeX will get really ugly.
So there I was naively saying
\parfillskip 0pt plus 100pt
in the hope this would make sure the horizontal space at the end of the last line of every paragraph was at most 100pt wide.
But witness the result of my MWE:
\documentclass[11pt]{article}
\usepackage{lipsum}
\begin{document}
\parfillskip 0pt plus 100pt
\let\opar\par
\def\par{\opar\hbox to \linewidth{\hfill\vrule width100pt height\fboxrule}}
\lipsum
\end{document}
You'll see that the 100pt are disregarded even by 'unproblematic' paragraphs. \sloppy
doesn't really help either, so the problem doesn't really lie in the fact that there is not enough material to stretch out.
Here's an extreme example:
The rule indicates the point to which the last line should stretch.
Looking at the resulting box yields
.\hbox(7.60416+0.0)x360.0, glue set 2.49602
..\OT1/cmr/m/n/10.95 c
..\OT1/cmr/m/n/10.95 u
..\OT1/cmr/m/n/10.95 r
..\discretionary
...\OT1/cmr/m/n/10.95 -
..\OT1/cmr/m/n/10.95 s
..\OT1/cmr/m/n/10.95 u
..\OT1/cmr/m/n/10.95 s
..\glue 3.65 plus 1.825 minus 1.21666
..\OT1/cmr/m/n/10.95 l
..\OT1/cmr/m/n/10.95 u
..\OT1/cmr/m/n/10.95 c
..\discretionary
...\OT1/cmr/m/n/10.95 -
..\OT1/cmr/m/n/10.95 t
..\OT1/cmr/m/n/10.95 u
..\OT1/cmr/m/n/10.95 s
..\glue 3.65 plus 1.825 minus 1.21666
..\OT1/cmr/m/n/10.95 m
..\OT1/cmr/m/n/10.95 a
..\OT1/cmr/m/n/10.95 u
..\discretionary
...\OT1/cmr/m/n/10.95 -
..\OT1/cmr/m/n/10.95 r
..\OT1/cmr/m/n/10.95 i
..\OT1/cmr/m/n/10.95 s
..\OT1/cmr/m/n/10.95 .
..\penalty 10000
..\glue(\parfillskip) 0.0 plus 100.0
..\glue(\rightskip) 0.0
So I assume the glue set 2.49602
is applied to the \parfillskip
glue, yielding 249.6pt, which looks more or less like what's on the screenshot.
My question is now: Is there another solution to get the intended effect in TeX?
Edit: I found that adding \usepackage[latin]{babel}
will make the 'problem' go away in this case, but the real "text" I need to typeset is a list of symbols with spaces between them. They need to be spaced out in any manner such that the last line is not too short, so the real application is much nearer to the MWE I'm giving (without proper hyphenation).
Conclusion Thanks to David, my original application now works like a charm:
I think the pictograms slightly stretched out look much better than the alternative with only one pictogram in the last line!
Best Answer
works for me to keep all the last lines inside the ruled area.
Alternatively you can do
But that works by s t r e t ch i n g the last line only, so looks rather horrible. Or you could do a combination of the two....