1

i want to do table, where i indicate the best results of tests. To do it i have to bold properly rows and columns. With

\Xcline{2-5}{2pt}

i can bold rows, but how can i do the same thing with columns?enter image description here

Code which i use to draw table:

\begin{table}[ht!]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
\diagbox{board}{tag} & tag1 & tag2 & tag3 &  tag4 \\ \hline
 \multirow{3}{*}{board1} & qr & dm & ar & ap \\ \cline{2-5} &
 qr  & dm & ar & ap \\ \cline{2-5} &
 qr  & dm & ar & ap \\ \cline{2-5} \hline
 \multirow{3}{*}{board2} & qr  & dm & ar & ap \\ \cline{2-5} &
 qr & dm & ar & ap \\ \cline{2-5} &
 qr & dm & ar & ap \\ \cline{2-5} \hline\Xcline{2-5}{1.5pt}
  \multirow{3}{*}{board3} & qr & dm & ar & ap \\ \cline{2-5} &
 qr & dm & ar & ap \\ \cline{2-5} &
 qr & dm & ar & ap \\ \cline{2-5} \hline \Xcline{2-5}{1.5pt}
\end{tabular}
\caption{Table_caption}
\end{center}
\end{table}

2 Answers2

4

I propose this solution, which relies on the boldline package (shipunov bundle), which defines lines of variable thickness for tables, both horizontal and vertical. It uses as an argument a number which represents the multiple of default line thickness. In the following code, I used 5, which means a thickness of 2pt:

\documentclass[12pt,fleqn]{article}
\usepackage{pict2e}
\usepackage{keyval}
\usepackage{calc}
\usepackage{fp}
\usepackage{diagbox}
\usepackage{booktabs}
\usepackage{tabularx,colortbl, makecell, caption, multirow}
\usepackage{boldline} 

\begin{document}

\begin{table}[htb!]
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
\diagbox{board}{tag} & tag1 & tag2 & tag3 & tag4 \\ \hline
 \multirow{3}{*}{board1} & qr & dm & ar & ap \\ \cline{2-5} &
 qr & dm & ar & ap \\ \cline{2-5} &
 qr & dm & ar & ap \\ \cline{2-5} \hline
 \multirow{3}{*}{board2} & qr & dm & ar & ap \\ \cline{2-5} &
 qr & dm & ar & ap \\ \cline{2-5} &
 qr & dm & ar & ap \\ \cline{2-5} \hline\clineB{2-5}{5}
\multirow{3}{*}{board3}& \multicolumn{1}{V{5}c|}{qr} & dm & ar & \multicolumn{1}{|cV{5}}{ap} \\ \cline{2-5}
 &\multicolumn{1}{V{5}c|}{qr} & dm & ar & \multicolumn{1}{|cV{5}}{ap} \\ \cline{2-5}
 &\multicolumn{1}{V{5}c|}{qr} & dm & ar & \multicolumn{1}{|cV{5}}{ap} \\[2pt] %
\hline
\noalign{\vskip-2.4pt}\clineB{2-5}{5}
\end{tabular}
\caption{Table caption}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350
1

Here is a way to do that table with {NiceTabular} of nicematrix.

  • In {NiceTabular}, you merge cells vertically and horizontally with the command \Block. You can ``draw'' around the block with the key draw.

  • The key hvlines draws all the rules excepted in the blocks (but if the key transparent is used for the blocks, the rules are drawn).

  • {NiceTabular} has a built-in command \diagbox (however, that command doesn't set the size of the cell and that's why I have put a \rule).

However, you need several compilations.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{table}[ht!] \centering \begin{NiceTabular}{wc{1.3cm}cccc}[hvlines] \rule[-8pt]{0pt}{20pt} \diagbox{board}{tag} & tag1 & tag2 & tag3 & tag4 \ \Block{3-1}{board1} & qr & dm & ar & ap \
& qr & dm & ar & ap \
& qr & dm & ar & ap \ \Block{3-1}{board2} & qr & dm & ar & ap \ & qr & dm & ar & ap \ & qr & dm & ar & ap \ \Block{3-1}{board3} & \Block[transparent,draw,line-width=2pt]{3-4}{} qr & dm & ar & ap \ & qr & dm & ar & ap \ & qr & dm & ar & ap \end{NiceTabular} \caption{Table caption} \end{table}

\end{document}

Output of the first code

If you want the bold line within the block, it's also possible but it's a little more complicated (and you have to load Tikz).

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}

\begin{document}

\begin{table}[ht!] \centering \begin{NiceTabular}{wc{1.3cm}cccc}[hvlines] \rule[-8pt]{0pt}{20pt} \diagbox{board}{tag} & tag1 & tag2 & tag3 & tag4 \ \Block{3-1}{board1} & qr & dm & ar & ap \
& qr & dm & ar & ap \
& qr & dm & ar & ap \ \Block{3-1}{board2} & qr & dm & ar & ap \ & qr & dm & ar & ap \ & qr & dm & ar & ap \ \Block{3-1}{board3} & \Block[transparent,tikz={clip},tikz={draw,line width=2pt}]{3-4}{} qr & dm & ar & ap \ & qr & dm & ar & ap \ & qr & dm & ar & ap \end{NiceTabular} \caption{Table caption} \end{table}

\end{document}

Output of the second code

F. Pantigny
  • 40,250