# Is there a way to avoid short lines?

Is there a universal setting to tell TeX that the last line of a paragraph can not have just one word? For instance, instead of this:

This is a sample paragraph and there is one word
here.

you would have that:

This is a sample paragraph and there is
one word here.

Also, is there something comparable to InDesign's Balance Ragged Lines? Instead of this:

With centered text it would be better if more words were
on this line.

you would get that:

With centered text it would be better
if more words were on this line.

For information, I'm currently using LuaLaTex, the memoir class and the fontspec, microtype packages.

-
Does this help? - tex.stackexchange.com/questions/28357/… – topskip May 18 '13 at 14:15
A decidedly low-tech way would be to insert ties (~) manually between the penultimate and final words of a paragraph. – Mico May 18 '13 at 17:59
Suppose you have a two line paragraph with only one word in the second line. It's quite improbable that another word can be accommodated in the second line without stretching too much spaces in the first line. Even adding ties would not help, because TeX might prefer hyphenation, if the alternative is worse, based on the current parameters. Only long enough paragraph allow for tricks like those outlined in the linked answers. Or a ragged right setting, of course. – egreg May 19 '13 at 22:03
I suppose I should have broken this into 2 questions, because the second example is really about centered text. The first example, in real life, would usually have more than one line of text. – theobear May 20 '13 at 13:46
The comments seem to be about adding extra words to the last line, you can also use \looseness=-1 to try and get the extra word onto the previous line. – StrongBad May 24 '13 at 17:48

As long as your paragraphs are long enough to make it feasible you can limit the stretch of the \parfillskip that pads the final line. It is not so easy to specifically refer to a single word, but you can make it stretch at most (say) half the line). You may need to increase \emergencystretch or \tolerance to allow the rest of the paragraph enough flexibility to push the extra words on to the last line:

\documentclass{article}

\setlength\textwidth{6cm}

\def\a{One two three four five six. }
\def\b{\a\a\a\a}

\begin{document}

Red yellow green. \b Blue black white bad.

\bigskip\hrule\bigskip

\setlength\parfillskip{0pt plus .4\textwidth}
\setlength\emergencystretch{.1\textwidth}

Red yellow green. \b Blue black white bad.
\end{document}


Similarly if you make the glue used for centering have only finite stretch:

\documentclass{article}

\setlength\textwidth{9cm}

\def\a{One two three four five six. }
\def\b{\a\a\a\a}

\begin{document}

\begin{center}
With centered text it would be better if more words were
on this line.
\end{center}

{\csname @flushglue\endcsname=0pt plus .25\textwidth
\begin{center}
With centered text it would be better if more words were
on this line.
\end{center}}

\end{document}

-
This doesn't seem to work with the parcolumns package... any idea of a work around? – theobear Jun 11 '13 at 23:10
@theobear paracol.sty ? – David Carlisle Jun 11 '13 at 23:37
ctan.org/pkg/parcolumns – theobear Jun 12 '13 at 1:11
I'm acutally using parcolumns and parcolsx (found here: tex.stackexchange.com/a/63997/26651) to do some side by side translations within the main text. your solution works for the main text but is ignored in the columns.... which is a pity as using the ~ tie seems to mess up the columns. – theobear Jun 14 '13 at 9:41