我是 LaTeX 新手。这个问题与如何在一个单元格中插入两种颜色?
答案中的相关代码很有帮助@user30471:H 列类型使用包collcell
将命令 \Heat 应用于每个单元格条目。但是,我的表上有超过 18 列。我尝试使用 \begin{tabular}{ cc *18H }
创建热图表作为该问题,但可能允许的最大列数\Heat
是 9。我\Heat
从@user30471 复制了代码。我的表格代码是:
\begin{document}
\begin{table}[h]
\centering
\caption{Summary of power ($\times1000$)... }
\setlength{\tabcolsep}{4.2pt}
\renewcommand{\arraystretch}{.8}
\begin{tabular}{r rrrrrr rrrrrr rrrrrr}
\toprule
& \multicolumn{6}{c}{minp1} & \multicolumn{6}{c}{minp2} & \multicolumn{6}{c}{treep}\\
\cmidrule(l){2-7}\cmidrule(l){8-13}\cmidrule(l){14-19}
% \begin{sidewaystable}[h]
$\tau$ & i & ii & iii & iv & v & vi & i & ii & iii & iv & v & vi & i & ii & iii & iv & v & vi \\
\midrule
& \multicolumn{18}{c}{0\% censoring}\\
% \begin{sidewaystable}[h]
-0.8 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100\\
-0.6 & 97 & 98 & 98 & 97 & 98 & 98 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100\\
-0.4 & 76 & 76 & 76 & 76 & 76 & 76 & 90 & 92 & 92 & 91 & 91 & 92 & 87 & 88 & 88 & 84 & 88 & 88\\
-0.2 & 22 & 22 & 22 & 22 & 22 & 23 & 29 & 31 & 32 & 31 & 30 & 33 & 26 & 25 & 25 & 25 & 24 & 27\\
0 & 6 & 6 & 6 & 6 & 6 & 4 & 4 & 5 & 4 & 4 & 4 & 5 & 5 & 4 & 3 & 3 & 3 & 6\\
0.2 & 13 & 14 & 14 & 14 & 13 & 14 & 30 & 31 & 33 & 32 & 33 & 28 & 27 & 25 & 25 & 25 & 25 & 27\\
0.4 & 39 & 39 & 40 & 40 & 40 & 40 & 94 & 95 & 95 & 95 & 95 & 95 & 85 & 89 & 87 & 87 & 88 & 87\\
0.6 & 80 & 81 & 82 & 82 & 81 & 81 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100\\
0.8 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100\\
[1ex]
& \multicolumn{18}{c}{25\% censoring}\\
-0.8 \\
% -0.7 \\
-0.6 \\
% -0.5 \\
-0.4 \\
% -0.3 \\
-0.2 \\
% -0.1 \\
0 \\
0.2 \\
0.4 \\
0.6 \\
0.8 \\
[1ex]
& \multicolumn{18}{c}{50\% censoring}\\
-0.8 \\
-0.6 \\
-0.4 \\
-0.3 \\
-0.2 \\
-0.1 \\
0 \\
0.2 \\
0.4 \\
0.6 \\
0.8 \\
\bottomrule
\end{tabular}
\label{tab: 1cut}
\end{table}
\Heatset{min=0, % maximum value
max=100, % minimum value
max colour=Gray0, % colour at maximum
min colour=Snow1, % colour at minimum
}
\begin{table}[h]
\caption{Summary of power ($\times1000$)... }
\setlength{\tabcolsep}{4.2pt}
\renewcommand{\arraystretch}{.8}
\begin{tabular}{cc * 9H}
\toprule
& \multicolumn{3}{c}{minp1} & \multicolumn{3}{c}{minp2} & \multicolumn{3}{c}{treep}\\
\cmidrule(l){1-3}\cmidrule(l){4-6}\cmidrule(l){7-9}
& &\multicolumn1c{i}&\multicolumn1c{ii}&\multicolumn1c{iii}&\multicolumn1c{iv}&\multicolumn1c{v}&\multicolumn1c{vi}&\multicolumn1c{i}&\multicolumn1c{ii}&\multicolumn1c{iii}\\
& -0.8& 100& 100& 100& 100& 100& 100& 100& 100& 100\\
& -0.6& 97 & 98 & 98 & 97 & 98 & 98 & 100& 100& 100\\
& -0.4& 76 & 76 & 76 & 76 & 76 & 76 & 90 & 90& 90\\
& -0.2& 22 & 22 & 22 & 22 & 22 & 23 & 29& 29& 29 \\
\rotatebox{90}{\makebox[0pt]{\textsf{$\tau$}}}
& 0& 6 & 6 & 6 & 6 & 6 & 4 & 4& 4& 4\\
& 0.2& 13 & 14 & 14 & 14 & 13 & 14 & 30& 30& 30\\\
& 0.4& 39 & 39 & 40 & 40 & 40 & 40 & 94 & 94 & 94\\
& 0.6& 80 & 81 & 82 & 82 & 81 & 81 & 100 & 100& 100\\
& 0.8& 100& 100& 100& 100& 100& 100& 100& 100& 100\\
\end{tabular}
\end{table}
\begin{tabular}{r rrrrrr rrrrrr rrrrrr}
如何通过修改代码来填充热图颜色?或者有其他方法可以创建类似的表格?
答案1
当列大于9时,应该\begin{tabular}{cc * {10}H}
不是\begin{tabular}{cc * 10H}
。