# How do I set right alignment in a longtable column with a fixed width?

How do I set right alignment in a longtable column with a fixed width?

I have \begin{longtable}{p{3cm}p{8cm}}

and I'd like my first column to be aligned on the right.

-

You can define a new column as

\newcolumntype{R}{>{\raggedleft\arraybackslash}p{3cm}}


The MWE:

\documentclass{article}
\usepackage{lipsum}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{6cm}}
%
\begin{document}
\begin{longtable}{Rp{8cm}}\toprule
col1 & col2 \\\midrule
\lipsum[1] & \lipsum[2]  \\ \bottomrule
\end{longtable}
\end{document}


PS. The package booktabs is used to get beautiful rules instead of \hline.

-
That works perfectly, thanks a lot! –  Costanza Aug 7 '12 at 6:52