Is it possible to right align the text in the last row of a justified textblock

horizontal alignmentparagraphsragged2e

is there a way to right align a text, which is at the same time justified? This particularly points onto the last line of the paragraph, which is normaly left aligned, or for example a very short one line paragraph, which would also appear as left alligned, although it is justified.

Thanks for the help! 🙂

Best Answer

The \leftskip TeX primitive register saves the skip used at each left side of the paragraph line. The skip can be streatchable, for example 0pt plus1fil. The \rightskip TeX primitive register saves the skip used at each right side of the paragraph line. It can be "negative stretachable". It does not mean shrinkable, but it eliminates the positive stretchable amount from \leftskip. The \parfillskip TeX primitive register is set by default (by plain TeX for example) to 0pt plus1fil. It is added at the end of the last line of the paragraph. If we set:

\leftskip=0pt plus1fil
\rightskip=0pt plus-1fil

test text ...
\bye

then all lines of paragraph (but not the last one) have only \leftskip at left side and \rightskip at right side. Their sum is zero, so only glu between words are used for justification. The last line have -1fil form \rightskip and 1fil from \parfillskip at right side. Their sum is zero. But there is another 1fil from \leftskip. This skip is stretched and the result is like shown in another answer here. This another answer uses LaTeX specific syntax for setting TeX primitive registers.

Related Question