The following code in the MWE below makes the last (current) row shown on the respective slide overlayed in green:
\begin{tabular}{cc}
\cellcolor<+>{green} A & B \\
\cellcolor<+>{green} C & D \\
\cellcolor<+>{green} E & F \\
\cellcolor<+>{green} D & E \\
\cellcolor<+>{green} F & G
end{tabular}
This is great, but I need to add \cellcolor<+>{green}
at the beginning of every line. Is there a way to define a new environment, say ovtab
, which works exactly like tabular
except that it does this automatically such that
\begin{ovtab}{cc}
A & B \\
C & D \\
E & F \\
D & E \\
F & G
end{ovtab}
produces the same result?
Full MWE:
\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}{Cell Coloring with In-out Effects}
\begin{center}
\begin{tabular}{cc}
\cellcolor<+>{green} A & B \\
\cellcolor<+>{green} C & D \\
\cellcolor<+>{green} E & F \\
\cellcolor<+>{green} D & E \\
\cellcolor<+>{green} F & G
\end{tabular}
\end{center}
\end{frame}
\end{document}