[Tex/LaTex] beamer cellcolor overlay

beameroverlaystables

My question is, how to implement the following overlay for tables in beamer.

  1. rows are shown one-by-one.
  2. rows are shown in sync with an "itemize" in the same slide.
  3. rows have different background colour.

I used the answer from
Cell coloring (highlighting) with in-out effects in a table in beamer
to do this, but my first column always has a colour in all rows in all slides!!

Here is a MWE:

\documentclass[xcolor=table]{beamer}

\rowcolors{1}{gray!30}{gray!10}

\makeatletter
\def\rowcolor{\noalign{\ifnum0=`}\fi\bmr@rowcolor}
\newcommand<>{\bmr@rowcolor}{%
    \alt#1%
        {\global\let\CT@do@color\CT@@do@color\@ifnextchar[\CT@rowa\CT@rowb}% 
        {\ifnum0=`{\fi}\@gooble@rowcolor}% 
}

\newcommand{\@gooble@rowcolor}[2][]{\@gooble@rowcolor@}
\newcommand{\@gooble@rowcolor@}[1][]{\@gooble@rowcolor@@}
\newcommand{\@gooble@rowcolor@@}[1][]{\ignorespaces}
\makeatother



\makeatletter
\def\cellcolor{{\ifnum0=`}\fi\bmr@cellcolor}
\newcommand<>{\bmr@cellcolor}{%
    \alt#1%
        {\global\let\CT@do@color\CT@@do@color\@ifnextchar[\CT@rowa\CT@rowb}% 
        {\ifnum0=`{\fi}\@gooble@cellcolor}% 
}

\newcommand{\@gooble@cellcolor}[2][]{\@gooble@cellcolor@}
\newcommand{\@gooble@cellcolor@}[1][]{\@gooble@cellcolor@@}
\newcommand{\@gooble@cellcolor@@}[1][]{\ignorespaces}
\makeatother


\begin{document}
\begin{frame}{The MWE}%

\rowcolors{2}{blue!30}{blue!10}
\begin{itemize}
\item \visible<1->{Item1}
\item \visible<2->{Item2}
\item \visible<3->{Item3}
\end{itemize}
\begin{center}
\begin{tabular}{cc}
    \visible<1->{Title1 & Title2} \\
    \hline
    \visible<1->{A1 & B1} \\
    \visible<2->{A2 & B2} \\
    \visible<3->{A3 & B3} \\
\end{tabular}
\end{center}
\end{frame}

\end{document}

Best Answer

Setting \rowcolors acts globally. You want to just affect each row at a time:

\documentclass[xcolor=table]{beamer}

\makeatletter
\def\rowcolor{\noalign{\ifnum0=`}\fi\bmr@rowcolor}
\newcommand<>{\bmr@rowcolor}{%
    \alt#1%
        {\global\let\CT@do@color\CT@@do@color\@ifnextchar[\CT@rowa\CT@rowb}%
        {\ifnum0=`{\fi}\@gooble@rowcolor}%
}

\newcommand{\@gooble@rowcolor}[2][]{\@gooble@rowcolor@}
\newcommand{\@gooble@rowcolor@}[1][]{\@gooble@rowcolor@@}
\newcommand{\@gooble@rowcolor@@}[1][]{\ignorespaces}
\makeatother



\makeatletter
\def\cellcolor{{\ifnum0=`}\fi\bmr@cellcolor}
\newcommand<>{\bmr@cellcolor}{%
    \alt#1%
        {\global\let\CT@do@color\CT@@do@color\@ifnextchar[\CT@rowa\CT@rowb}%
        {\ifnum0=`{\fi}\@gooble@cellcolor}%
}

\newcommand{\@gooble@cellcolor}[2][]{\@gooble@cellcolor@}
\newcommand{\@gooble@cellcolor@}[1][]{\@gooble@cellcolor@@}
\newcommand{\@gooble@cellcolor@@}[1][]{\ignorespaces}
\makeatother


\begin{document}
\begin{frame}{The MWE}%

\begin{itemize}
\item \visible<1->{Item1}
\item \visible<2->{Item2}
\item \visible<3->{Item3}
\end{itemize}
\begin{center}
\begin{tabular}{cc}
    \rowcolor<1->{blue!30}\visible<1->{Title1 & Title2} \\
    \hline
    \rowcolor<1->{blue!10}\visible<1->{A1 & B1} \\
    \rowcolor<2->{blue!30}\visible<2->{A2 & B2} \\
    \rowcolor<3->{blue!10}\visible<3->{A3 & B3} \\
\end{tabular}
\end{center}
\end{frame}

\end{document}

Row colouring in beamer