Error while setting column width in Latex: Package array Error: Illegal pream-token (3cm): c' used

This is my code to build a simple table.

\begin{table}
\small
\centering
\begin{tabular}{ l{3cm}|l|l|l}
....
\hline
\end{tabular}
\end{table}


But, I am getting the error Package array Error: Illegal pream-token (3cm):c' used.

Any ideas on how to get around this?

• l{3cm} isn't allowed because this columntype is not defined with a length. Either use p{3cm} or define a new columntype with the array package and \newcolumntype{L}[1]{\raggedleft\arraybackslash}p{#1}}. You can use L{3cm} then – user31729 May 29 '16 at 15:04
• Use p{3cm}. l can have no length. – Bernard May 29 '16 at 15:04

Here's the way to do to it with array and \newcolumntype.

\documentclass{article}

\usepackage{array}

\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}
\begin{table}
\small
\centering
\begin{tabular}{L{3cm}|l|l|R{5cm}}
A & B & C & D \tabularnewline
\hline
\end{tabular}
\end{table}
\end{document}


• I kept the vertical lines on purpose. Of course, the table does not look well, but that wasn't the question – user31729 May 29 '16 at 17:21