我尝试过 \cellcolor、\rowcolor ... 但这总是导致整个表格着色。鉴于我的表格实现,我该如何为单元格着色?谢谢
\documentclass[annual]{acmsiggraph}
\usepackage{amsfonts}
\usepackage{array,graphicx}
\usepackage[thinlines]{easytable}
\title{Dice Probability}
\author{Xavier Dupont\thanks{e-mail: [email protected]}}
\pdfauthor{Xavier Dupont}
\keywords{Dice, Probability}
\newcommand\ML[1]{\llap{#1\quad}}
\begin{document}
\begin{tabular}{c}
\begin{TAB}(e,1cm,1cm){ccccccc}{ccccccc}
Dice {\color{blue}$B$}
\end{TAB}\\[-\normalbaselineskip]
\begin{TAB}(e,1cm,1cm){|c|c|c|c|c|c|c|}{|c|c|c|c|c|c|c|}
\ML{} \textbf{\LARGE +} & {\color{blue}0} & {\color{blue}1} & {\color{blue}2} & {\color{blue}3} & {\color{blue}4} & {\color{blue}5}\\
\ML{} {\color{red}1} & 2 & 3 & 4 & 5 & 6 & 7 \\
\ML{} {\color{red}2} & 3 & 4 & 5 & 6 & 7 & 8 \\
\ML{} {\color{red}3} & 4 & 5 & 6 & 7 & 8 & 9 \\
\ML{} {\color{red}4} & 5 & 6 & 7 & 8 & 9 & 10 \\
\ML{} {\color{red}5} & 6 & 7 & 8 & 9 & 10 & 11 \\
\ML{} {\color{red}6} & 7 & 8 & 9 & 10 & 11 & \cellcolor{red!50}{12} \\
\end{TAB}
\end{tabular}
\end{document}
答案1
我希望这个构造对你有用,由于某种原因我无法运行你的示例,我的包管理器无法识别它acmsiggraph
并且没有安装它。
\documentclass[12pt,a4paper]{book}
\usepackage{colortbl} %color de tabla
\usepackage{setspace} %espacio en tablas
\usepackage{xcolor}
\begin{document}\begin{spacing}{1.3}
\begin{tabular}{|c|c|c| >{\columncolor{yellow!50}[1.0\tabcolsep]} c|c| c|}
\hline
A & B & C & D & E & Total \\
\hline
F & 1 & 2 & 3 & 4 & 10 \\
\hline
\rowcolor{green!50}[1.0\tabcolsep]
G & & & $s$ & & $n$ \\
\hline
H & & & & & \\
\hline
Total & & & $m$ & & \cellcolor{red!50} $t$ \\
\hline
\end{tabular} \\
\end{spacing}
\end{document}