答案1
您hhline
可以使用~
“此列中没有行”说明符和-
“此列中只有一行”说明符。因此第二行将是\hhline{-|=|=|=|=|=|=|=|=|}
。
不过,我同意评论中的观点,行数越少通常越好。在以下四个 MWE 变体中,我更喜欢第三个或第四个(但绝对不是第一个)。
\documentclass{article}
\usepackage{hhline}
\begin{document}
\begin{tabular}{|l||r|r|r|r|r|r|r|r|}
\hhline{~--------}
\multicolumn{1}{c}{} & \multicolumn{4}{|c|}{Validation} & \multicolumn{4}{|c|}{Testing}\\
\hhline{-|=|=|=|=|=|=|=|=|}
Method & Precision & Recall & F1-score & MCC & Precision & Recall & F1-score & MCC\\
\hline
Naive Bayes & 0.6 & 0.8 & 0.7 & 0.4 & 0.5 & 0.7 & 0.6 & 0.3\\
LSTM & 0.7 & 0.9 & 0.8 & 0.6 & 0.6 & 0.8 & 076 & 0.4\\
\hline
\end{tabular}
\vspace{1cm}
\begin{tabular}{|l|rrrr|rrrr|}
\hhline{~--------}
\multicolumn{1}{c}{} & \multicolumn{4}{|c|}{Validation} & \multicolumn{4}{|c|}{Testing}\\
\hline
Method & Precision & Recall & F1-score & MCC & Precision & Recall & F1-score & MCC\\
\hline
Naive Bayes & 0.6 & 0.8 & 0.7 & 0.4 & 0.5 & 0.7 & 0.6 & 0.3\\
LSTM & 0.7 & 0.9 & 0.8 & 0.6 & 0.6 & 0.8 & 076 & 0.4\\
\hline
\end{tabular}
\vspace{1cm}
\begin{tabular}{l|rrrr|rrrr}
\multicolumn{1}{c}{} & \multicolumn{4}{c}{Validation} & \multicolumn{4}{c}{Testing}\\
\hline
Method & Precision & Recall & F1-score & MCC & Precision & Recall & F1-score & MCC\\
\hline
Naive Bayes & 0.6 & 0.8 & 0.7 & 0.4 & 0.5 & 0.7 & 0.6 & 0.3\\
LSTM & 0.7 & 0.9 & 0.8 & 0.6 & 0.6 & 0.8 & 076 & 0.4\\
\hline
\end{tabular}
\vspace{1cm}
\begin{tabular}{lrrrrrrrr}
\multicolumn{1}{c}{} & \multicolumn{4}{c}{Validation} & \multicolumn{4}{c}{Testing}\\
\hline
Method & Precision & Recall & F1-score & MCC & Precision & Recall & F1-score & MCC\\
\hline
Naive Bayes & 0.6 & 0.8 & 0.7 & 0.4 & 0.5 & 0.7 & 0.6 & 0.3\\
LSTM & 0.7 & 0.9 & 0.8 & 0.6 & 0.6 & 0.8 & 076 & 0.4\\
\hline
\end{tabular}
\end{document}
结果:
答案2
{NiceTabular}
如果您确实想要这些双重规则,您也可以使用of来实现nicematrix
。此环境在单元格、行和列下创建 PGF/Tikz 节点,您可以在构建数组后使用它们用 Tikz 绘制您想要的任何规则。
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
\begin{NiceTabular}{l!{\hskip1mm}rrrrrrrr}[corners=NW,vlines]
\Hline
& \Block{1-4}{Validation} &&&& \Block{1-4}{Testing}\\[1mm]
\Hline
Method & Precision & Recall & F1-score & MCC & Precision & Recall & F1-score & MCC\\
\Hline
Naive Bayes & 0.6 & 0.8 & 0.7 & 0.4 & 0.5 & 0.7 & 0.6 & 0.3\\
LSTM & 0.7 & 0.9 & 0.8 & 0.6 & 0.6 & 0.8 & 076 & 0.4\\
\Hline
\CodeAfter
\tikz \draw ([xshift=-1mm]2-|2) -- ([xshift=-1mm]last-|2)
([yshift=1mm]2-|2) -- ([yshift=1mm]2-|last) ;
\end{NiceTabular}
\end{document}
您需要多次编译(因为nicematrix
使用 PGF/Tikz 节点)。