1

enter image description here

So the current table looks like this, in which I add \hhline{|=|=|=|=|=|=|=|=|=|}, however, I would like there isn't a double divider on top of "Method".

I tried \hhline{=|=|=|=|=|=|=|=|=|} and \hhline{==|=|=|=|=|=|=|=|=|}, but doesn't work.

2
  • 1
    Is there really a need for all the double rules, both horizontally and vertically? Why not follow the advice of booktabs: "You will not go far wrong if you remember two simple guidelines at all times: 1. Never, ever use vertical rules. 2. Never use double rules."?
    – Werner
    Apr 13 '21 at 6:24
  • You can try \hhline{-::=::=::=::=||=::=::=::=|}.
    – Bernard
    Apr 13 '21 at 8:47
1

With hhline you can use the ~ specifier for 'no line in this column' and the - specifier for 'single line in this column'. So the second line would be \hhline{-|=|=|=|=|=|=|=|=|}.

However, I agree with the comments that less lines is generally better. In the MWE below four variants, I would prefer the third or maybe the fourth (but definitely not the first).

\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}

Result:

enter image description here

0

If you actually want these double rules, you can also do that with {NiceTabular} of nicematrix. This environment creates PGF/Tikz nodes under the cells, rows and columns and you can use them to draw whatever rule you want with Tikz after the construction of the array.

 \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}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.