4

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?

  • 3
    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
  • 2
    Use p{3cm}. l can have no length. – Bernard May 29 '16 at 15:04
3

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}

enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.