# New command causes undefined control sequence [duplicate]

I want to create a new command to set the column colour, but it's causing the following error:

! Undefined control sequence.
\redcolumn ->\columncolor
{red}
l.10 A & B
\\


I don't know if it's because I'm calling a command with a parameter or because of where I'm trying to call the new command, but here's the source code:

\documentclass[letterpaper,20pt]{extarticle}
\usepackage[table,xcdraw]{xcolor}
\newcommand{\redcolumn}{\columncolor{red}}
\begin{document}
\begin{tabular}{l >{\columncolor{red}}l}
A & B \\
\end{tabular}

\begin{tabular}{l >{\redcolumn}l}
A & B \\
\end{tabular}

\end{document}


The first tabular uses \columncolor, and it works. The second uses my new command, and it fails. How have I misunderstood \newcommand?

## marked as duplicate by David Carlisle macros StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Nov 17 '15 at 8:00

Thanks to Jérôme's comment, I was able to find a solution: use \newcolumntype instead of \newcommand:

\documentclass[letterpaper,20pt]{extarticle}
\usepackage[table,xcdraw]{xcolor}
\newcolumntype{R}{>{\columncolor{red}}l}
\begin{document}
\begin{tabular}{l >{\columncolor{red}}l}
A & B \\
\end{tabular}

\begin{tabular}{l R}
A & B \\
\end{tabular}

\end{document}


It's probably weird to use R for a left-aligned column, but it stands for red.