# Centered-justified or right-justified

How can I get justified text, with the last line in each paragraph centered, or justified text with the last line flush right? Is there a typographic reason why I cannot find this setting?

See subsection 18.3.1 of TeX by Topic.

The solution for a centered last line is to put the following lines in your document:

\leftskip=0cm plus 0.5fil \rightskip=0cm plus -0.5fil
\parfillskip=0cm plus 1fil


MWE:

\documentclass{article}
\usepackage{lipsum}

\leftskip=0cm plus 0.5fil \rightskip=0cm plus -0.5fil
\parfillskip=0cm plus 1fil

\begin{document}
\lipsum
\end{document}


Output:

If you want right alignement for the last line, change

\parfillskip=0cm plus 1fil


to

\parfillskip=0cm plus 0.5fil


• Thanks. I don't have time in the next week or two to review the code you've given me, but I'll accept your answer when I do. – ahorn Oct 31 '16 at 10:15