我的问题是,如何在 beamer 中实现表格的以下覆盖。
- 行逐行显示。
- 行与同一张幻灯片中的“项目”同步显示。
- 行有不同的背景颜色。
我使用了 在投影仪的表格中使用进出效果对单元格进行着色(突出显示) 这样做,但我的第一列在所有幻灯片的所有行中总是有一种颜色!!
以下是 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}
答案1
设置\rowcolors
作用于全局。你只想一次影响每一行:
\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}