我想逐个为元素着色。在我的示例中,我只想先将 3 涂成蓝色,而不是 3,0。该怎么做?
\begin{table}
\centering
\begin{tabular}{|c|c|c|}
\toprule
\diagbox{Player 1}{Player 2} & Left (L)~~ & Right (R)~ ~ \\
\hline
Up (U) & \color<2->{blue}{3},0 & 0,-4 \\
\hline
Down (D) & 2,4 & -1,8 \\
\bottomrule
\end{tabular}
\end{table}
答案1
使用{\color<2->{blue}{3}},0
应该会产生预期的输出:
由于包中的行booktabs
与垂直线不兼容,因此我在最终的 MWE 中还包含了两种替代表格布局:
全部三个示例的完整代码:
\documentclass{beamer}
%%%%% Packages needed for the first example table %%%%%
\usepackage{booktabs}
\usepackage{diagbox}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Packages needed for the seconf and third example table %%%%%
\usepackage[column=0]{cellspace}
\setlength{\cellspacetoplimit}{\tabcolsep}
\setlength{\cellspacebottomlimit}{\cellspacetoplimit}
\usepackage{multirow}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}
\begin{table}
\centering
\begin{tabular}{|c|c|c|}
\toprule
\diagbox{Player 1}{Player 2} & Left (L)~~ & Right (R)~ ~ \\
\hline
Up (U) & {\color<2->{blue}{3}},0 & 0,-4 \\
\hline
Down (D) & 2,4 & -1,8 \\
\bottomrule
\end{tabular}
\end{table}
\end{frame}
\begin{frame}
\begin{table}
\centering
\begin{tabular}{0c0r *{2}{>{$}wr{0.75cm}<{$}@{,}>{$}wl{0.75cm}<{$}}}
& \multicolumn{1}{c}{} & \multicolumn{4}{0c}{Player 2}\\
& & \multicolumn{2}{0c}{Left (L)} & \multicolumn{2}{0c}{Right (R)} \\
\multirow{2.75}{*}{Player 1} & Up (U) & \color<2->{blue}{3} & 0 & 0 &-4 \\
& Down (D) & 2 & 4 & -1 & 8 \\
\end{tabular}
\end{table}
\end{frame}
\begin{frame}
\begin{table}
\centering
\begin{tabular}{|0c|0r| *{2}{>{$}wr{0.75cm}<{$}@{,}>{$}wl{0.75cm}<{$}|}}
\cline{3-6}
\multicolumn{2}{c|}{} & \multicolumn{4}{0c|}{Player 2}\\
\cline{3-6}
\multicolumn{2}{c|}{} & \multicolumn{2}{0c|}{Left (L)} & \multicolumn{2}{0c|}{Right (R)} \\
\hline
\multirow{2.75}{*}{Player 1} & Up (U) & \color<2->{blue}{3} & 0 & 0 &-4 \\
\cline{2-6}
& Down (D) & 2 & 4 & -1 & 8 \\
\hline
\end{tabular}
\end{table}
\end{frame}
\end{document}