使用下面给出的代码,由于 ,我在“Methods”一词上出现了一条黑线hhline
。我该如何删除这条黑线或使其颜色与背景颜色相同,以使其不可见?
\documentclass{article}
\usepackage{hhline}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{hhline}
\usepackage{multirow}
\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\begin{document}
\begin{table}[]
\centering
\setlength\arrayrulewidth{1.3pt}
\footnotesize\setlength{\tabcolsep}{2.7 pt}
\renewcommand{\arraystretch}{1.4}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\cellcolor{aliceblue} & \multicolumn{2}{c|}{\cellcolor{babyblue}ISE} & \multicolumn{2}{c|}{\cellcolor{babyblue}IAE} & \multicolumn{2}{c|}{\cellcolor{babyblue}ITAE} \\ \hhline{-|-|-|-|-|-|-|} \cline{2-7}
\multirow{-2}{*}{\cellcolor{aliceblue} Methods}
& \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% & \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% & \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% \\ \hhline{-|*6-}
\rowcolor{babyblue}ABC & 0.5645 & 0.63 & 1.8 & 1.8 & 6.1 & 6.6 \\ \hhline{-|*6-}
\rowcolor{aliceblue}XYZ & 2.1 & 2.3 & 0.881 & 9.82 & 9.2 & 28.9 \\ \hhline{-|*6-}
\rowcolor{babyblue}MNO & 0.68 & 0.97 & 1.62 & 1.61 & 8.9 & 8.2 \\ \hhline{-|*6-}
\rowcolor{aliceblue} PQR & 0.65 & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \\ \hhline{-|*6-}
\end{tabular}
\end{table}
\end{document}
答案1
您需要将使用的命令更改\hhline{-|-|-|-|-|-|-|}
为\hhline{|~|-|-|-|-|-|-|}
(参见~
第一个位置标记,其中应该没有线)。
因此以下 MWE
\documentclass{article}
\usepackage{hhline}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{multirow}
\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\begin{document}
\begin{table}[]
\centering
\setlength\arrayrulewidth{1.3pt}
\footnotesize\setlength{\tabcolsep}{2.7 pt}
\renewcommand{\arraystretch}{1.4}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\cellcolor{aliceblue} & \multicolumn{2}{c|}{\cellcolor{babyblue}ISE} & \multicolumn{2}{c|}{\cellcolor{babyblue}IAE} & \multicolumn{2}{c|}{\cellcolor{babyblue}ITAE} \\
\hhline{|~|-|-|-|-|-|-|} % <==========================================
\multirow{-2}{*}{\cellcolor{aliceblue}Methods}
& \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% & \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% & \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% \\ \hhline{-|*6-}
\rowcolor{babyblue}ABC & 0.5645 & 0.63 & 1.8 & 1.8 & 6.1 & 6.6 \\ \hhline{-|*6-}
\rowcolor{aliceblue}XYZ & 2.1 & 2.3 & 0.881 & 9.82 & 9.2 & 28.9 \\ \hhline{-|*6-}
\rowcolor{babyblue}MNO & 0.68 & 0.97 & 1.62 & 1.61 & 8.9 & 8.2 \\ \hhline{-|*6-}
\rowcolor{aliceblue} PQR & 0.65 & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \\ \hhline{-|*6-}
\end{tabular}
\end{table}
\end{document}
结果如下表:
因为不想删除这些行,所以我删除了第二个表。
要删除文本“方法”下的底层白线,您需要将命令更改\hhline{|~|-|-|-|-|-|-|}
为
\hhline{|>{\arrayrulecolor{aliceblue}}->{\arrayrulecolor{black}}|-|-|-|-|-|-|}
请注意,此代码打印了线的第一部分(-
再次用 标记;~
添加白线!)并将其染成与背景相同的颜色。
使用以下 MWE
\documentclass{article}
\usepackage{hhline}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{multirow}
\usepackage{booktabs}
\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\begin{document}
\begin{table}[ht]
\centering
\setlength\arrayrulewidth{1.3pt}
\footnotesize\setlength{\tabcolsep}{2.7 pt}
\renewcommand{\arraystretch}{1.4}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\cellcolor{aliceblue} & \multicolumn{2}{c|}{\cellcolor{babyblue}ISE} & \multicolumn{2}{c|}{\cellcolor{babyblue}IAE} & \multicolumn{2}{c|}{\cellcolor{babyblue}ITAE} \\
\hhline{|>{\arrayrulecolor{aliceblue}}->{\arrayrulecolor{black}}|-|-|-|-|-|-|} % <==========================================
\multirow{-2}{*}{\cellcolor{aliceblue}Methods}
& \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% & \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% & \cellcolor{aliceblue}-20\% & \cellcolor{aliceblue}+20\% \\ \hhline{-|*6-}
\rowcolor{babyblue}ABC & 0.5645 & 0.63 & 1.8 & 1.8 & 6.1 & 6.6 \\ \hhline{-|*6-}
\rowcolor{aliceblue}XYZ & 2.1 & 2.3 & 0.881 & 9.82 & 9.2 & 28.9 \\ \hhline{-|*6-}
\rowcolor{babyblue}MNO & 0.68 & 0.97 & 1.62 & 1.61 & 8.9 & 8.2 \\ \hhline{-|*6-}
\rowcolor{aliceblue} PQR & 0.65 & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \\ \hhline{-|*6-}
\end{tabular}
\end{table}
\end{document}
得到结果:
答案2
我会重新设计你的表格如下:
\documentclass{article}
\usepackage{siunitx}
\usepackage[table]{xcolor}
\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\usepackage{booktabs, multirow}
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}
\begin{document}
\begin{table}[htb]
\centering
\renewcommand\arraystretch{1.2}
\rowcolors{2}{white}{aliceblue}
\begin{tabular}{c *{6}{S} }
\toprule
& \mcc{ISE} & \mcc{IAE} & \mcc{ITAE} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
\multirow{-2.3}{*}{Methods}
& {$-20\%$} & {$+20\%$}
& {$-20\%$} & {$+20\%$}
& {$$-20\%$} & {$+20\%$} \\
\hline
ABC & 0.5645 & 0.63 & 1.8 & 1.8 & 6.1 & 6.6 \\
XYZ & 2.1 & 2.3 & 0.881 & 9.82 & 9.2 & 28.9 \\
MNO & 0.68 & 0.97 & 1.62 & 1.61 & 8.9 & 8.2 \\
PQR & 0.65 & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案3
这是 \multirow 中白线的解决方案。\hhline{~|-|-|-|-|-|-|}
我没有使用,而是使用了全宽\hhline
,但使第一段具有 \multirow 的背景颜色。
我还擅自简化了您的代码,并使用了AliceBlue
来自的颜色svgnames
,因为它看起来与您的没有什么不同aliceblue
。
\documentclass{article}
\usepackage{hhline}
\usepackage[table, svgnames]{xcolor}
\usepackage{array}
\usepackage{multirow}
\usepackage{booktabs}
\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\begin{document}
\begin{table}[ht]
\centering
\setlength\arrayrulewidth{1.3pt}
\footnotesize\setlength{\tabcolsep}{2.7 pt}
\renewcommand{\arraystretch}{1.4}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\cellcolor{aliceblue} & \multicolumn{2}{c|}{\cellcolor{babyblue}ISE} & \multicolumn{2}{c|}{\cellcolor{babyblue}IAE} & \multicolumn{2}{c|}{\cellcolor{babyblue}ITAE} \\
\hhline{|>{\arrayrulecolor{AliceBlue}}->{\arrayrulecolor{black}}|*6{-}} % <==========================================
\rowcolor{AliceBlue} \multirow{-2}{*}{Methods}
&$ - $20\% & +20\% & $ - $20\% & +20\% & $ - $20\% & +20\% \\ \hhline{-|*6-}
\rowcolor{babyblue}ABC & 0.5645 & 0.63 & 1.8 & 1.8 & 6.1 & 6.6 \\ \hhline{-|*6-}
\rowcolor{AliceBlue}XYZ & 2.1 & 2.3 & 0.881 & 9.82 & 9.2 & 28.9 \\ \hhline{-|*6-}
\rowcolor{babyblue}MNO & 0.68 & 0.97 & 1.62 & 1.61 & 8.9 & 8.2 \\ \hhline{-|*6-}
\rowcolor{AliceBlue} PQR & 0.65 & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \\ \hhline{-|*6-}
\end{tabular}
\end{table}
\end{document}
答案4
{NiceTabular}
使用来制作该表很容易nicematrix
。
\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\begin{document}
\begin{table}[ht]
\centering
\setlength{\arrayrulewidth}{1.3pt}
\footnotesize
\setlength{\tabcolsep}{2.7 pt}
\renewcommand{\arraystretch}{1.4}
\begin{NiceTabular}{ccccccc}[hvlines,color-inside]
\rowcolors{babyblue}{aliceblue}
\Block[fill=aliceblue]{2-1}{Methods} & \Block{1-2}{ISE} && \Block{1-2}{IAE} && \Block{1-2}{ITAE} \\
&$-$20\% & +20\% & $-$20\% & +20\% & $-$20\% & +20\% \\
ABC & 0.5645 & 0.63 & 1.8 & 1.8 & 6.1 & 6.6 \\
XYZ & 2.1 & 2.3 & 0.881 & 9.82 & 9.2 & 28.9 \\
MNO & 0.68 & 0.97 & 1.62 & 1.61 & 8.9 & 8.2 \\
PQR & 0.65 & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \\
\end{NiceTabular}
\end{table}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。