6

I'm having an issue where \cline appears to be drawn under the fill for table colours.

With \hline

enter image description here

With \cline

(to remove the line above the cell I want blank)

enter image description here

The line is still there, only very very thin. This doesn't always display or print. Is there anything simple I can do to fix this?

Here's the source for my example:

\documentclass{article}

\usepackage[table]{xcolor}

%odd/eaven colours for tables
\rowcolors{2}{gray!10}{white}

%to change cells of the title row 
\newcommand{\titlecol}{\cellcolor{gray!30}}

\begin{document}

\begin{table}[!ht]
\centering
\begin{tabular}{|l| c c | c c |}
\cline{2-5}
%\hline
\rowcolor{white} %first cell is excluded from the table
\multicolumn{1}{c|}{} & \multicolumn{2}{c|}{\titlecol Title1} & \multicolumn{2}{c|}{\titlecol Title2} \\
\hline
A & 0 & 1 & 2 & 3 \\
B & 0 & 1 & 2 & 3 \\
C & 0 & 1 & 2 & 3 \\
D & 0 & 1 & 2 & 3 \\
\hline
\end{tabular}
\caption{Caption.}
\label{mytable}
\end{table}

\end{document}
  • What happens if you type \ \cline{2-5}? – Willem Van Onsem Feb 27 '14 at 22:46
  • @CommuSoft I get an error: Misplaced \omit. \@cline #1-#2\@nil ->\omit – jozxyqk Feb 27 '14 at 22:48
  • 2
    please read the colortbl documentation. cline is explicitly not supported. Use hhline instead. – David Carlisle Feb 27 '14 at 23:02
2

I found out the following: the line is not too thin, it is simply overwritten by the filled cells. Some pdf readers notice the small difference in y-value and paint the line, others don't.

A similar question has been asked here:

\cline doesn't work

I propose you solve this problem with one of the proposed methods as listed in the extended answer on this question.

| improve this answer | |
2

Thanks all for your answers and comments!

There's also this, now I know what to search for: Colored tables and cline/hhline

This is what I ended up with (using \hhline{~|--|--|}):

enter image description here

I've only looked briefly, but it looks like this is what the characters in hline do:

  • ~ no line for one cell
  • | the corner between horizontal and vertical lines, although I'm not sure if I needed the middle one
  • - the line for a cell

See the docs

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{hhline}

%odd/eaven colours for tables
\rowcolors{2}{gray!10}{white}

\newcommand{\titlecol}{\cellcolor{gray!30}}

\begin{document}

\begin{table}[!ht]
\centering
\begin{tabular}{|l| c c | c c |}
\hhline{~|*4{-}|}
%\cline{2-5}
%\hline
\rowcolor{white}
\multicolumn{1}{c|}{} & \multicolumn{2}{c|}{\titlecol Title1} & \multicolumn{2}{c|}{\titlecol Title2} \\
\hline
A & 0 & 1 & 2 & 3 \\
B & 0 & 1 & 2 & 3 \\
C & 0 & 1 & 2 & 3 \\
D & 0 & 1 & 2 & 3 \\
\hline
\end{tabular}
\caption{Caption.}
\label{mytable}
\end{table}

\end{document}
| improve this answer | |

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.