# Cancel \rowcolors for a specific cell

In some tables, the cell in the top-left corner is meant to be left empty. To do this in tables that use \rowcolors, I do \cellcolor{white}. However, I'm now using some old tables of this kind in a Beamer slideshow that has a background, so I'd like to be able to simply cancel the row colour for a specific cell (i.e., make a transparent cell that lets the background appear) rather than to fill it with white (which actually looks less pretty than simply leaving the cell as it is in such circumstances).

In the following code, I use a dumb \colorbox to fake the presence of a background for the third instance of the dummy table. Note that my real background is a gradient, so filling the cell with “the colour used in the background” is not a solution.

\documentclass{minimal}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}

\begin{document}

\newcommand{\emptycell}{}

\begin{tabular}{c c c}
\emptycell & A & B \\
Plop       & 1 & 2 \\
\end{tabular}

\rowcolors{1}{blue!15}{blue!10}
\renewcommand{\emptycell}{\cellcolor{white}}

\begin{tabular}{c c c}
\emptycell & A & B \\
Plop       & 1 & 2 \\
\end{tabular}

\colorbox{red!10}{%
\begin{tabular}{c c c}
\emptycell & A & B \\
Plop       & 1 & 2 \\
\end{tabular}%
}

\end{document}


I tried some pretty crazy stuff with no success. I went as far as this (go ahead, laugh at me):

\newcommand{\emptycell}{%
\multicolumn{1}{
>{%
\let\rowc@lors\relax%
\def\@evenrowcolor{\@norowcolor}%
\def\@oddrowcolor{\@norowcolor}%
\let\rownum\relax%
} c
}{}%
}


Thanks for your time.

## 1 Answer

You could try this here:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}

\begin{document}

\rowcolors{1}{blue!15}{blue!10}

\makeatletter
\global\let\oriCT@@do@color\CT@@do@color

\colorbox{red!10}{%
\begin{tabular}{c c c}
\global\let\CT@@do@color\relax           %deactivate
&
\global\let\CT@@do@color\oriCT@@do@color %reactivate
A
&
B \\
Plop       & 1 & 2 \\
\end{tabular}%
}

\end{document}


• Haha, I was kind of expecting some esoteric \relax-based things like this. Thanks. I had to fiddle a little bit in my true table because of siunitx columns, but everything was fine in the end. Too bad the reactivation has to be done manually (had to make a \restorecell command in addition to the \emptycell one), but that's a minor issue, I guess. – Alice M. Dec 4 '17 at 16:56