我想将颜色放入带有旋转文本的表格中的多行单元格中,但当我放入它时,文本会出现在颜色后面,如下例所示(是书的一部分 - 我使用的是 Springer 格式)
代码:
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage[bottom]{footmisc}
\usepackage{array}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{makecell}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{courier}
\usepackage{type1cm}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage[bottom]{footmisc}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{multirow}
。 。 。
\begin{document}
\definecolor{Gray}{gray}{0.85}
\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{7}{*}{\rotatebox[origin=c]{90}{\textbf{Experiment}}} & \cellcolor{Gray}\textbf{Date} & \cellcolor{Gray}\textbf{Target} & \cellcolor{Gray}\textbf{Count} & \cellcolor{Gray}\textbf{Observations} \\ \cline{2-5}
& 1 & Lamp & 21 & \\ \cline{2-5}
& 2 & Radio & 22 & \\ \cline{2-5}
\cellcolor{Gray} & 3 & Window & 24 & \multicolumn{1}{l|}{Medium Noise} \\ \cline{2-5}
& 4 & Door & 21 & \\ \cline{2-5}
& 5 & TV & 18 & \\ \cline{2-5}
& 6 & Phone & 24 & \\ \cline{2-5}
\hline
\end{tabular}
\caption{My Table.}
\label{tabla:final}
\end{table}
\end{document}
获取:
答案1
首先应绘制背景颜色,然后将文本放置在其上。该示例还用于\cellcolor{Gray}
完整的第一列:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{graphicx}
\begin{document}
\definecolor{Gray}{gray}{0.85}
\begin{table}
\centering
\begin{tabular}{|>{\cellcolor{Gray}}c|c|c|c|c|}
\hline
& \cellcolor{Gray}\textbf{Date} & \cellcolor{Gray}\textbf{Target}
& \cellcolor{Gray}\textbf{Count} & \cellcolor{Gray}\textbf{Observations}
\\ \cline{2-5}
& 1 & Lamp & 21 & \\ \cline{2-5}
& 2 & Radio & 22 & \\ \cline{2-5}
& 3 & Window & 24 & \multicolumn{1}{l|}{Medium Noise} \\ \cline{2-5}
& 4 & Door & 21 & \\ \cline{2-5}
& 5 & TV & 18 & \\ \cline{2-5}
\multirow{-7}{*}{\rotatebox[origin=c]{90}{\textbf{Experiment}}}
& 6 & Phone & 24 & \\ \cline{2-5}
\hline
\end{tabular}
\caption{My Table.}
\label{tabla:final}
\end{table}
\end{document}
答案2
当列已经着色时,替代解决方案是将multirow
单元格放在末尾:
\documentclass{article}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{multirow}
\begin{document}
\definecolor{Gray}{gray}{0.85}
\begin{table}[htb]
\centering
\begin{tabular}{|>{\columncolor{Gray}}c|c|c|c|c|}
\rowcolor{Gray}\hline
& \textbf{Date} & \textbf{Target} & \textbf{Count} & \textbf{Observations} \\
\cline{2-5}
& 1 & Lamp & 21 & \\
\cline{2-5}
& 2 & Radio & 22 & \\
\cline{2-5}
& 3 & Window & 24 & \multicolumn{1}{l|}{Medium Noise} \\
\cline{2-5}
& 4 & Door & 21 & \\
\cline{2-5}
& 5 & TV & 18 & \\
\cline{2-5}
\multirow{-7}{*}{\rotatebox[origin=c]{90}{\textbf{Experiment}}}
& 6 & Phone & 24 & \\
\hline
\end{tabular}
\caption{My Table.}
\label{tabla:final}
\end{table}
\end{document}