# Avoid single words or syllables in new line at the end of paragraphs

How can I tell latex to avoid single words or syllables in a new line at the end of paragraphs? Bonus points for being able to expand that to captions.

TeX doesn't have a specific control over the last word (You can always use ~ instead of space for the final spaces to prevent breaks there). As a general mechanism the best way is probably to control the length of the final line, so restricting the final line to be at least a certain length rather than at least a word. If you have very short paragraphs TeX may find it hard and generate over or underfull boxes, but then you need to either live with that or fix by hand.

Here I force the final line to be at least a quarter of the text width and add a bit of extra stretchability in the paragraph just to help tex adjust.

\documentclass{article}
\setlength\textwidth{6cm}
\begin{document}

Some text just to fill out the space.
Some text just to fill out the space.
Some text just to fill out the space.
Some text just to fill out the space.
Some text just to.

\setlength\parfillskip{0pt plus .75\textwidth}
\setlength\emergencystretch{1pt}
Some text just to fill out the space.
Some text just to fill out the space.
Some text just to fill out the space.
Some text just to fill out the space.
Some text just to.

\end{document}