我想为第 2 行的空单元格以及合并行着色。我该怎么做?
\documentclass{article}
\begin{document}
\begin{center}
\begin{tabular}{ |c| c| c |c |c |c|}
\hline
chapter & \multicolumn{5}{|c|}{rules in sub-chapters} \\
\hline
& first & second & third& fourth & total \\
\hline
first & 75 & 73 & 93 & 110 & 351 \\
\hline
second & 72 & 38 & 73 & 85 & 268 \\
\hline
total & \multicolumn{4}{|c|}{} & 3981 \\
\hline
\end{tabular}
\end{center}
\end{document}
答案1
您可能想要使用xcolor
该table
选项及其\cellcolor
。
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{center}
\begin{tabular}{ |c| c| c |c |c |c|}
\hline
chapter & \multicolumn{5}{c|}{rules in sub-chapters} \\
\hline
\cellcolor{green}& first & second & third& fourth & total \\
\hline
first & 75 & 73 & 93 & 110 & 351 \\
\hline
second & 72 & 38 & 73 & 85 & 268 \\
\hline
total & \multicolumn{4}{c|}{\cellcolor{green}} & 3981 \\
\hline
\end{tabular}
\end{center}
\end{document}
更新:正如 Mico 所建议的,您应该将\multicolumn
列定义更改为c|
而不是|c|
(出于列计算的原因)。