Attention: This is an advanced TeX problem.
I usually dislike lines that are too small, and so I tend to add
\parfilskip=2em plus 0.6\textwidth
to my documents (apart from small lines, this also avoids last lines that end too close to the right margin, making sure the paragraph ends at least 2ems from the margin).
My problem is on figures, in which I also like to have a centred last line. Memoir and other classes/packages provide a macro for this effect, eg \centerlastline from Memoir, which is defined as:
\leftskip=0pt plus 1fil
\rightskip=0pt plus -1fil
\parfilskip=0pt plus 2fil
This clever code allows the last line to be centred, but sometimes the last line is short (for example, only one word). What I would like to do is tweak that macro so that the stretchability is not an infinite stretch. My first approach was to try
\leftskip=0pt plus 0.3\textwidth
\rightskip=0pt plus -0.3\textwidth
\parfillskip=0pt plus 0.6\textwidth
My intuition was that for mid-paragraph lines, stretchability would be calculated as 0 and they would therefore be written in their right place, while the last like would have enough stretchability on the left and right to be absolutely centred. Unfortunately, this does not work, as the paragraph is then typeset in a wobbly way
\documentclass[10pt,a4paper]{article}
\usepackage{lipsum}
\begin{document}
\leavevmode \vskip-10em \parindent=0pt \hsize=12cm
\textbf{REGULAR}\par
\lipsum[1] \vskip\baselineskip
\textbf{REGULAR / NOT SMALL}\par
{\parfillskip=2em plus 0.6\textwidth
\lipsum[1]} \vskip\baselineskip
\textbf{CENTRED}\par
{\leftskip=0pt plus 1fil
\rightskip=0pt plus -1fil
\parfillskip=0pt plus 2fil
\lipsum[1]} \vskip\baselineskip
\textbf{CENTRED / NOT SMALL}\par
{\leftskip=0pt plus 0.3\textwidth
\rightskip=0pt plus -0.3\textwidth
\parfillskip=0pt plus 0.6\textwidth
\lipsum[1]} \vskip\baselineskip
\end{document}
The problem (as far as I can see) is that spaces also contribute to the stretchability of a line. This means that:
- the total stretchability of the mid-paragraph lines is not 0
- and so it gets distributed,
- which means that the left margin gets a positive value and the right margin the corresponding negative value
- finally leading to loose lines being shifted to the right (tight lines do not stretch at all and so they are set in place).
Any thoughts on this problem?

