我正在处理下表,其中的命令没有在和条目\cline{2-4}
之间绘制水平线:Timed
Untimed
你能给我一些建议来修复它吗?
\documentclass[varwidth]{standalone}
\usepackage[table]{xcolor}
\usepackage[english]{babel}
\usepackage{multirow}
\usepackage{mathtools}
\newcommand\nocell[1]{\multicolumn{#1}{c|}{}}
\begin{document}
\begin{center}
\renewcommand{\arraystretch}{1.9}
\begin{tabular}{|c |c |c |c|}
\cline{3-4}
\nocell{2} & \multicolumn{2}{|c|}{$\vcenter{\hbox{\bfseries\cellcolor[rgb]{1.0,0.0,0.22} \text{Centrality}}}$}\\
\hline
\cline{3-4}
\nocell{2} & \cellcolor[rgb] {1.0,0.33,0.64}Centralized & \cellcolor[rgb]{1.0,0.65,0.79} Decentralized\\
\hline
\cellcolor[rgb]{0.0,0.5,1.0} & \cellcolor[rgb]{0.4,0.6,0.8} Untimed & Chapter 3 & Chapter 4\\
\cline{2-4}
\multirow{-2}{*}{\bfseries\cellcolor[rgb]{0.0,0.5,1.0} Temporality}
& \cellcolor[rgb]{0.0,0.75,1.0} Timed & Chapter 5 & Chapter 6\\
\hline
\end{tabular}
\end{center}
\end{document}
答案1
一些与彩色单元格相邻的水平线不显示的问题众所周知。您应该能够在此网站上找到不少关于此主题的帖子。
从美学角度来说,一个更严重的问题是,你似乎在表格中混淆了两种用于分隔单元格的视觉隐喻:(a) 绘制水平线和垂直线,以及 (b) 使用颜色。我认为最好坚持使用其中一种隐喻——并且不是同时使用两者。
这是一个消除所有水平和垂直线的解决方案。
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage[english]{babel}
\usepackage{multirow}
\begin{document}
\begin{center}
\renewcommand{\arraystretch}{1.9}
\begin{tabular}{l ccc}
%\cline{3-4}
&& \multicolumn{2}{c}{\bfseries\cellcolor[rgb]{1.0,0.0,0.22}Centrality}\\
%\cline{3-4}
& & \cellcolor[rgb]{1.0,0.33,0.64}Centralized\phantom
& \cellcolor[rgb]{1.0,0.65,0.79}Decentralized\\
%\hline
\cellcolor[rgb]{0.0,0.5,1.0}
& \cellcolor[rgb]{0.4,0.6,0.8}Untimed
& \cellcolor[rgb]{0.91,0.91,0.91}Chapter 3
& \cellcolor[rgb]{0.91,0.91,0.91}Chapter 4\\
%\cline{2-4}
\multirow{-2}{*}{\bfseries\cellcolor[rgb]{0.0,0.5,1.0}Temporality}
& \cellcolor[rgb]{0.0,0.75,1.0}Timed
& \cellcolor[rgb]{0.91,0.91,0.91}Chapter 5
& \cellcolor[rgb]{0.91,0.91,0.91}Chapter 6\\
%\hline
\end{tabular}
\end{center}
\end{document}
答案2
使用hhline
包:
\documentclass[varwidth]{standalone}
\usepackage[table]{xcolor}
\usepackage[english]{babel}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{mathtools}
\newcommand\nocell[1]{\multicolumn{#1}{c|}{}}
\begin{document}
\begin{center}
\renewcommand{\arraystretch}{1.9}
\begin{tabular}{|c |c |c |c|}
\hhline{~~--}
\nocell{2} & \multicolumn{2}{c|}{$\vcenter{\hbox{\bfseries\cellcolor[rgb]{1.0,0.0,0.22} \text{Centrality}}}$}\\
%\cline{3-4}
\hhline{~~--}
\nocell{2} & \cellcolor[rgb] {1.0,0.33,0.64}Centralized & \cellcolor[rgb]{1.0,0.65,0.79} Decentralized\\
\hline
\cellcolor[rgb]{0.0,0.5,1.0} & \cellcolor[rgb]{0.4,0.6,0.8} Untimed & Chapter 3 & Chapter 4\\
\hhline{>{\arrayrulecolor[rgb]{0.0,0.5,1.0}}->{\arrayrulecolor{black}}---}
\multirow{-2}{*}{\bfseries\cellcolor[rgb]{0.0,0.5,1.0} Temporality}
& {\cellcolor[rgb]{0.0,0.75,1.0}} Timed & Chapter 5 & Chapter 6\\
\hline
\end{tabular}
\end{center}
\end{document}
答案3
紧接着添加以下代码\cline{2-4}
:
\omit \vrule height.4pt\textcolor[rgb]{0,.5,1}{\leaders\vrule\hfil}\vrule \cr
解释:在“行-行”完成后\cline
执行\noalign{\kern -rulewidth}
。因此,以下单元格与输出重叠\cline
。我们可以先尝试添加\noalign{\kern.4pt}
后面\cline
的单元格以补偿负的字距。但在这种情况下,第一个浅蓝色单元格不连续。漏洞就在这里。因此,第二次尝试是通过上面的代码“填补这个漏洞”。