1

I'm using booktabs to create table and use cmidrule to span a line across a few columns. The problem is when the cells have background color, the spaces around cmidrule makes it look really bad.

While, booktabs allow you to trim the left and right side of cmidrule, I don't see the options for setting spaces above and below it to 0.

This is the code I have:

\begin{table}
\centering
\begin{tabular}{lcc}    
\bfrule       % this is specialrule with no spaces above and below
\rowcolor[gray]{.8}
\multirow{2}{*}{}           & \multicolumn{2}{c}{\textbf{Big group}} \\
                    %\cline{2-3}
                    \cmidrule(){2-3}
\rowcolor[gray]{.8}         &  subgroup1 &  subgroup2 \\
\hline
Item 1      & 10 & 50\\
Item 2          &  5 & 25 \\
\bfrule
\end{tabular}
\end{table}

and this is what I got. enter image description here

Is there any way to fix that?

Thanks,

Update

As David pointed out in his comment, removing spaces won't solve the problem. There's still thin line of white color at the left and/or right of the midline.

enter image description here

cgnieder
  • 66,645
chepukha
  • 770
  • 2
  • 8
  • 13
  • even if you reduce the space to 0pt so the colour touches the rules, you will still have a white line at either end of the cline, are you sure you want to mix the formal style of booktabs with the more casual style of colortbl? – David Carlisle Nov 28 '15 at 22:02
  • you're probably right. I'm not familiar with colortbl. I'm just trying to work around booktabs as I've already had a few tables using it. My ultimate goal is to have the a line spanning a few columns without breaking the cell background color. – chepukha Nov 28 '15 at 22:08
  • colortbl is the package providing the background colour in your example (probably loaded via xcolor's table option) – David Carlisle Nov 28 '15 at 22:10
  • ah, I see what you mean. yes, I used xcolor's table option to color the row. – chepukha Nov 28 '15 at 22:16

1 Answers1

2

Playing with hhline and the boldline package produces a more acceptable result:

    \documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{newtxtext,newtxmath}
\usepackage[table, x11names]{xcolor}
\usepackage{graphicx}
\usepackage{multirow, float, booktabs, boldline, hhline}
\usepackage{cellspace}

\begin{document}

\begin{table}
  \centering
  \begin{tabular}{lcc}
    \hlineB{2} % this is specialrule with no spaces above and below
    \rowcolor[gray]{.8}
    \multirow{2}{*}{\cellcolor[gray]{.8}} & \multicolumn{2}{c}{\textbf{Big group}} \\
    %\cline{2-3}
    \hhline{>{\arrayrulecolor [gray]{0.8}}->{\arrayrulecolor {black}}--}
    \rowcolor[gray]{.8} & subgroup1 & subgroup2 \\
    \hlineB{1.5}
    Item 1 & 10 & 50 \\
    Item 2 & 5 & 25 \\
    \hlineB{2}
  \end{tabular}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350