This question already has an answer here:

I'm compiling this code and as result I have this table:

enter image description here

\begin{table}[!h]
\centering
\begin{tabular}{cc|c|c}
\toprule
                                                                                      &                                                              & \textbf{$\mathcal{J}$ fairness index}           & \textbf{TB size}                                \\
\midrule
                                                                                      & \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} $16 \times 8$} & \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} } & \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} } \\ \cline{2-4} 
                                                                                      & \cellcolor[HTML]{C0C0C0}$16 \times 4$                        & \cellcolor[HTML]{C0C0C0}                        & \cellcolor[HTML]{C0C0C0}                        \\ \cline{2-4} 
\multirow{-3}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}BLIND\\ METHOD\end{tabular}}}     & \cellcolor[HTML]{EFEFEF}$4 \times 4$                         & \cellcolor[HTML]{EFEFEF}                        & \cellcolor[HTML]{EFEFEF}                        \\ \midrule
                                                                                      & \cellcolor[HTML]{9B9B9B}$16 \times 8$                        & \cellcolor[HTML]{9B9B9B}                        & \cellcolor[HTML]{9B9B9B}                        \\ \cline{2-4} 
                                                                                      & \cellcolor[HTML]{C0C0C0}$16 \times 4$                        & \cellcolor[HTML]{C0C0C0}                        & \cellcolor[HTML]{C0C0C0}                        \\ \cline{2-4} 
\multirow{-3}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}TRAINING\\ METHOD\end{tabular}}}  & \cellcolor[HTML]{EFEFEF}$4 \times 4$                         & \cellcolor[HTML]{EFEFEF}                        & \cellcolor[HTML]{EFEFEF}                        \\ \midrule
                                                                                      & \cellcolor[HTML]{9B9B9B}$16 \times 8$                        & \cellcolor[HTML]{9B9B9B}                        & \cellcolor[HTML]{9B9B9B}                        \\ \cline{2-4} 
                                                                                      & \cellcolor[HTML]{C0C0C0}$16 \times 4$                        & \cellcolor[HTML]{C0C0C0}                        & \cellcolor[HTML]{C0C0C0}                        \\ \cline{2-4} 
\multirow{-3}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}HEURISTIC\\ METHOD\end{tabular}}} & \cellcolor[HTML]{EFEFEF}$4 \times 4$                         & \cellcolor[HTML]{EFEFEF}                        & \cellcolor[HTML]{EFEFEF}                        \\ \bottomrule
\end{tabular}
\caption{•}
\label{tab_fairness_los}
\end{table}

I would like to know how I can make the cline between coloured cells appear? Any idea? Is there something wrong in the code? Do I need a particular package?

If I use \hline instead of \cline this is what happens: enter image description here Sincerely I don't know how I should write

marked as duplicate by boycott.se - yo', user13907, barbara beeton, Keks Dose, Svend Tveskæg Oct 2 '15 at 20:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • and colortbl package documentations says: % \section{Less fun with \cs{cline}} % Lines produced by "\cline" are coloured if you use % "\arrayrulecolor" but you may not notice as they are covered up by % any colour pannels in the following row. This is a `feature' of % "\cline". If using this package you would probably better using the % "-" rule type in a "\hhline" argument, rather than "\cline" – David Carlisle Oct 2 '15 at 14:48
  • don't use [h!] generally it just makes latex give a warning that it is changing it to ht but it is almost always best to include p as well, otherwise the float is very restricted and more likely to go to the end of the docuemnt as it has no legal place to go. – David Carlisle Oct 2 '15 at 14:50
  • @DavidCarlisle I'm using this package: %\usepackage[table,xcdraw]{xcolor}. I try to use \hhline but nothing change. – Mattia Oct 2 '15 at 14:59
  • If you have a version with hhline that overprints (even when you zoom in) then edit the question to show that – David Carlisle Oct 2 '15 at 15:05
  • @DavidCarlisle I edit, but I don't know how I should write down the changes you suggest. – Mattia Oct 2 '15 at 15:11
up vote 2 down vote accepted

Just use package hhline (add \usepackage{hhline}) and use \hhline{~-|-|-} instead of your \cline{2-4}. In the documentation of package hhline (use texdoc hhline on your terminal) you can find: ~ for no line and - for a line in the column ...

But just a remark: Why do you use lines and colored cells? Your colored cells marks very well what you want, you really do not need the lines in the table here. A good typography for tables is to use as less as you can. Start with no vertical lines ...

The complete MWE:

\documentclass{scrartcl}

\usepackage{hhline}
\usepackage{booktabs}
\usepackage[table,xcdraw]{xcolor}
\usepackage{multirow}

\begin{document}

\begin{table}
\centering
\begin{tabular}{cc|c|c}
\toprule
                                                                                      &                                                              & \textbf{$\mathcal{J}$ fairness index}           & \textbf{TB size}                                \\
\midrule
                                                                                      & \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} $16 \times 8$} & \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} } & \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} } \\ \hhline{~-|-|-} 
                                                                                      & \cellcolor[HTML]{C0C0C0}$16 \times 4$                        & \cellcolor[HTML]{C0C0C0}                        & \cellcolor[HTML]{C0C0C0}                        \\ \hhline{~-|-|-} 
\multirow{-3}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}BLIND\\ METHOD\end{tabular}}}     & \cellcolor[HTML]{EFEFEF}$4 \times 4$                         & \cellcolor[HTML]{EFEFEF}                        & \cellcolor[HTML]{EFEFEF}                        \\ \midrule
                                                                                      & \cellcolor[HTML]{9B9B9B}$16 \times 8$                        & \cellcolor[HTML]{9B9B9B}                        & \cellcolor[HTML]{9B9B9B}                        \\ \hhline{~-|-|-} 
                                                                                      & \cellcolor[HTML]{C0C0C0}$16 \times 4$                        & \cellcolor[HTML]{C0C0C0}                        & \cellcolor[HTML]{C0C0C0}                        \\ \hhline{~-|-|-} 
\multirow{-3}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}TRAINING\\ METHOD\end{tabular}}}  & \cellcolor[HTML]{EFEFEF}$4 \times 4$                         & \cellcolor[HTML]{EFEFEF}                        & \cellcolor[HTML]{EFEFEF}                        \\ \midrule
                                                                                      & \cellcolor[HTML]{9B9B9B}$16 \times 8$                        & \cellcolor[HTML]{9B9B9B}                        & \cellcolor[HTML]{9B9B9B}                        \\ \hhline{~-|-|-} 
                                                                                      & \cellcolor[HTML]{C0C0C0}$16 \times 4$                        & \cellcolor[HTML]{C0C0C0}                        & \cellcolor[HTML]{C0C0C0}                        \\ \hhline{~-|-|-} 
\multirow{-3}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}HEURISTIC\\ METHOD\end{tabular}}} & \cellcolor[HTML]{EFEFEF}$4 \times 4$                         & \cellcolor[HTML]{EFEFEF}                        & \cellcolor[HTML]{EFEFEF}                        \\ \bottomrule
\end{tabular}
\caption{•}
\label{tab_fairness_los}
\end{table}

\end{document}

and the result:

enter image description here

  • this is exactly what I was looking for! Thanks – Mattia Oct 3 '15 at 8:28
  • Kurt, I have one more question for you. In the result table I obtain (also in your here reported) are present some dot's on the left of the three methods in the first column. How I can remove those points? Any suggestions? Thanks for your help. – Mattia Oct 3 '15 at 21:47
  • 1
    @Mattia Ups, I oversaw two leading | in the \hhline commands. Please change \hhline{|~|-|-|-} to \hhline{~-|-|-} (delete the two leading |). Sorry. – Kurt Oct 4 '15 at 5:56

Here is a solution, with a simplified code,thanks to the makecell package, which allows for line breaks in cells and a common formatting.

Also, booktabs produces white strips in coloured rows due to its vertical padding of rules. So I propose to use instead the small boldline package (from the shipunov bundle) and add some vertical padding above and below rows with the cellspace package.

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{bm}
\usepackage{multirow, booktabs}
\usepackage{hhline, boldline, makecell}
\renewcommand\cellset{\bfseries}
\usepackage[table]{xcolor}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{3pt}

\begin{document}

\begin{table}[!h]
\centering
\begin{tabular}{cSc|Sc|c}
\hlineB{2.4}%
& &$\bm{\mathcal{J}}$ \textbf{fairness index} & \textbf{TB size} \\
\hlineB{1.5}%
& \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} $16 \times 8$} & \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} } & \cellcolor[HTML]{9B9B9B}{\color[HTML]{000000} } \\
\hhline{~---} %
& \cellcolor[HTML]{C0C0C0}$16 \times 4$ & \cellcolor[HTML]{C0C0C0} & \cellcolor[HTML]{C0C0C0}\\
\hhline{~---} %
\multirowcell{-3}{BLIND\\ METHOD}& \cellcolor[HTML]{EFEFEF}$4 \times 4$ & \cellcolor[HTML]{EFEFEF} & \cellcolor[HTML]{EFEFEF} \\
\hlineB{1.5}%
& \cellcolor[HTML]{9B9B9B}$16 \times 8$ & \cellcolor[HTML]{9B9B9B} & \cellcolor[HTML]{9B9B9B}\\
\hhline{~---} %
& \cellcolor[HTML]{C0C0C0}$16 \times 4$ & \cellcolor[HTML]{C0C0C0} & \cellcolor[HTML]{C0C0C0}\\
\hhline{~---} %
\multirowcell{-3}{TRAINING\\ METHOD} & \cellcolor[HTML]{EFEFEF}$4 \times 4$ & \cellcolor[HTML]{EFEFEF} & \cellcolor[HTML]{EFEFEF} \\
\hlineB{1.5}%\midrule
& \cellcolor[HTML]{9B9B9B}$16 \times 8$ & \cellcolor[HTML]{9B9B9B} & \cellcolor[HTML]{9B9B9B}\\
\hhline{~---} %
& \cellcolor[HTML]{C0C0C0}$16 \times 4$ & \cellcolor[HTML]{C0C0C0} & \cellcolor[HTML]{C0C0C0}\\
\hhline{~---} %
\multirowcell{-3}{HEURISTIC\\ METHOD} & \cellcolor[HTML]{EFEFEF}$4 \times 4$ & \cellcolor[HTML]{EFEFEF} & \cellcolor[HTML]{EFEFEF} \\
\hlineB{2.4}
\end{tabular}
\caption{•}
\label{tab_fairness_los}
\end{table}

\end{document} 

enter image description here

  • Thanks Bernard, but I think that the other solution works better. Thanks anyway for the effort. – Mattia Oct 3 '15 at 8:30

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