[Tex/LaTex] Raggedleft paragraph in a table

horizontal alignmenttables

I am trying to typeset a table of two columns, where each column
consists of paragraphs and the paragraphs in the right hand column are
set raggedleft. Here is a minimal example of the code I thought would work:

\documentclass{article}
\usepackage{array}
\newcommand{\lorem}{Lorem ipsum dolor sit amet, consectetur adipisicing elit.}
\begin{document}
  \begin{tabular}{p{50mm}>{\raggedleft}p{50mm}}
  \lorem&\lorem\\
  \lorem&\lorem
  \end{tabular}
\end{document}

However, that produces the error message

! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate

l.7   \lorem&
     \lorem
? 

and the output is not at all what I expected either.

Is there a better way?

Best Answer

You have to restore \\ for use in tabular after inserting switches like \raggedleft in the last column. See the array manual for details.

\documentclass{article}
\usepackage{array}

\newcommand{\lorem}{Lorem ipsum dolor sit amet, consectetur adipisicing elit.}

\begin{document}
  \begin{tabular}{p{5cm}>{\raggedleft\arraybackslash}p{5cm}}
    \lorem&\lorem\\
    \lorem&\lorem
  \end{tabular}
\end{document}