[Tex/LaTex] cm – illegal unit of measure in tabular

errorstablestabularx

I wanted to created a table and I get an illegal unit of measure error, but I use cm, which works great normally…. I don't know why but sometimes I get this error and sometimes it works great…
enter image description here

 \documentclass[12pt]{article}


\usepackage[ngerman]{babel}
\usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry}
\usepackage[sfdefault]{ClearSans}
\usepackage[utf8]{inputenc}
\setlength{\parskip}{1.2ex}
\setlength{\parindent}{0em}
\usepackage{tabularx}

\begin{document}

\title{Stundenplanung Selbstverteidigung}
\date{}
\maketitle

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

\begin{tabular}{L{4cm}L{4cm}L{3cm}}
Name & Material & Anleitung \\

\end{tabular}
\end{document}

Best Answer

You have to add a # in every of your \newcolumntype definitions:

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

\newcolumntype defines a macro with one argument, this argument(the column width) can be accessed by #1.

Related Question