How do I right-align the last line of a justified paragraph?

2,199

If you want the entire cell contents to be justified, except the last line to be right justified (\raggedleft), you can use the following length settings (original source):

\leftskip=0pt plus .5fil
\rightskip=0pt plus -.5fil
\parfillskip=0pt plus .5fil

Here is a minimal working example (MWE) showing this in a tabular with p{5cm} column and some dummy text (provided by the lipsum package):

Right-to-left alignment in tabular

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\newcommand{\RTLpar}{% right-to-left paragraph alignment
  \leftskip=0pt plus .5fil%
  \rightskip=0pt plus -.5fil%
  \parfillskip=0pt plus .5fil%
}
\begin{document}
\begin{tabular}{p{5cm}}
  \RTLpar%
  \lipsum[1]
\end{tabular}
\end{document}​

The MWE provides \RTLpar (short for "right-to-left paragraph") which modified these settings.

Share:
2,199

Related videos on Youtube

Rob
Author by

Rob

Updated on August 01, 2022

Comments

  • Rob
    Rob over 1 year

    I want to wrap around text in a table cell; therefore I use the p option in the definition of tabular. However, I'm writing in Hebrew, so it aligns the last line to the left, instead of to the right. Can it be solved?

    • Werner
      Werner almost 12 years
      How about just issuing \raggedleft inside the cell?
    • lockstep
      lockstep almost 12 years
    • Rob
      Rob almost 12 years
      That works, thanks! However it doesn't change the spaces' lengths so the lines align up. I can live with that, but is it possible to easily do that?
    • Rob
      Rob almost 12 years
      lockstep: That only centers, doesn't it? Can't find a way to make it right to left.
  • Peter Grill
    Peter Grill almost 12 years
    Anyone know the reason for the down vote on this? Seems to work fine for me.