I want to define a new command \tableheadline that (1) formats the headline text in some way and (2) takes an optional argument for spanning multiple columns while centering the headline.
I tried the following implementation:
\documentclass{minimal}
\newcommand{\tableheadline}[2][1]{\multicolumn{#1}{c}{\textit{#2}}}
% \newcommand{\tableheadline}[2][1]{\multicolumn{1}{c}{\textit{#2}}}
\begin{document}
\begin{tabular}[\textwidth]{cc}
\tableheadline[2]{C}
\tableheadline{A} & \tableheadline{B} \\
0 & 1 \\
2 & 3 \\
\end{tabular}
\end{document}
This, however, gives me an error:
! Misplaced \omit.
\multispan ->\omit
\@multispan
l.8 \tableheadline[2]{C}
I also get the error when I do not even use the optional argument (see commented line in the MWE). Any ideas what I am doing wrong?

\\\that you missed in the end of first tabular line) – koleygr Jul 02 '18 at 15:40