[Tex/LaTex] colortbl: \rowcolor in tables with \begin{tabular}{@{}ccc@{}}

colortbltables

I'm trying to make a table with the following code:

\begin{tabular}{@{}ccc@{}}
  \hline 
  \rowcolor[gray]{.9} a & b & c \\
  \hline
\end{tabular}

Unfortunately the \rowcolor command seems to not care about the empty leading and ending spaces in the table, i.e. the @{}'s in the tabular 'preamble'.

Any suggestions to overcome this issue are most welcome.

Best Answer

\documentclass[a4paper,12pt]{article}
\usepackage{colortbl}
\newcolumntype{C}{c<{\kern\tabcolsep}@{}}
\begin{document}

\begin{tabular}{@{}CCc@{}}\hline 
  \rowcolor[gray]{.9}[0pt][0pt] a & b & c \\\hline
\end{tabular}
\end{document}

enter image description here