4

In Why can't I wrap \rowcolor in \only? (Beamer), there are solutions to how to use \rowcolor with \only in Beamer. Is there a way to use \columncolor in a similar way?

Li Wang
  • 1,013

1 Answers1

4

The \columncolor macro seems to be very special handled1 and can't be patched to support beamer overlays. I would do it be using custom column types which are defined differently depending on the overlay:

\documentclass[table]{beamer}

\begin{document}

\begin{frame}<1-3>

\alt<2>
{\newcolumntype{a}{>{\columncolor{blue}}c}}
{\newcolumntype{a}{>{\columncolor{yellow}}c}}

\temporal<2>
{\newcolumntype{b}{c}}
{\newcolumntype{b}{>{\columncolor{green}}c}}
{\newcolumntype{b}{>{\columncolor{red}}c}}

\begin{tabular}{ab}
   A &  B \\
   A &  B \\
   A &  B \\
\end{tabular}

\end{frame}

\end{document}

1 In fact \columncolor is never defined at all! Another internal tabular macro simply scans the tabular preamble for it and extracts the argument of it!

David Carlisle
  • 757,742
Martin Scharrer
  • 262,582
  • Works perfectly! Although I do not fully understand the syntax...:) – Li Wang Jul 21 '11 at 10:01
  • @Lee: See the array package manual. >{code} adds the code before (>) every cell. There is also <{code} which adds it afterwards and must be used after the column character. – Martin Scharrer Jul 21 '11 at 10:04