Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

So I need to make a colored table with multirows, together with the use of partial horizontal lines. I used \cline which does not work: the \cellcolor-command overwrites the line. This question told me to change it to \hhline which will not be overwritten by \cellcolor. Instead, \hhline overwrites the color.

To make it more clear:

Without color:

\documentclass{article}

\usepackage{colortbl}
\usepackage{multirow}

\begin{document}

  \begin{tabular}{|c|c|}
    \hline
    \bfseries ColumnOne & \bfseries ColumnTwo\\ \hline
    First data & 932\\ \hline
     & 239\\ \cline{2-2}  % or \hhline{|~|-|}
     & 137\\ \cline{2-2}  % or \hhline{|~|-|}
    \multirow{-3}{*}{More data} & 319\\ \hline
    Last data & 132\\ \hline
  \end{tabular}

\end{document}

Using <code>\cline</code> without color

With color:
Using \cline

\documentclass{article}

\usepackage{colortbl}
\usepackage{multirow}

\begin{document}

  \begin{tabular}{|>{\columncolor{red}}c|>{\columncolor{blue}}c|}
    \hline
    \bfseries ColumnOne & \bfseries ColumnTwo\\ \hline
    First data & 932\\ \hline
     & 239\\ \cline{2-2}
     & 137\\ \cline{2-2}
    \multirow{-3}{*}{More data} & 319\\ \hline
    Last data & 132\\ \hline
  \end{tabular}

\end{document}

enter image description here Makes the lines in the right column disappear.

Using \hhline

\documentclass{article}

\usepackage{colortbl}
\usepackage{multirow}
\usepackage{hhline}

\begin{document}

  \begin{tabular}{|>{\columncolor{red}}c|>{\columncolor{blue}}c|}
    \hline
    \bfseries ColumnOne & \bfseries ColumnTwo\\ \hline
    First data & 932\\ \hline
     & 239\\ \hhline{|~|-|}
     & 137\\ \hhline{|~|-|}
    \multirow{-3}{*}{More data} & 319\\ \hline
    Last data & 132\\ \hline
  \end{tabular}

\end{document}

enter image description here Creates white lines on the left column.

Is there any possible way on how to resolve this?

share|improve this question
    
I'd recommend reading this answer on avoiding horizontal rules in tables. –  Brent.Longborough Jul 30 '12 at 13:46
    
Please do not edit my post without knowing the context, i.e. why I want to do this. I know what I'm doing and why I want to do it. –  Didii Jul 30 '12 at 13:56
    
@Didii: I agree; you can roll back an edit if you wish. –  Werner Jul 30 '12 at 14:08
    
I agree with Werner; please feel absolutely free to roll back the edit. It's worth mentioning, though, that one of the things that attract many of us here to TeX is the beauty of it's output, hence the warning, which was, please believe me, intended entirely in the spirit of friendship. –  Brent.Longborough Jul 30 '12 at 14:13
    
On reflection, and considering the opinions of friends, I've rolled it back. Please accept my apologies. –  Brent.Longborough Jul 30 '12 at 14:16

1 Answer 1

up vote 13 down vote accepted

I'm sorry the interface is not brilliant here: But you can do this:

\documentclass{article}

\usepackage{colortbl}
\usepackage{multirow}
\usepackage{hhline}

\begin{document}

  \begin{tabular}{|>{\columncolor{red}}c|>{\columncolor{blue}}c|}
    \hline
    \bfseries ColumnOne & \bfseries ColumnTwo\\ \hline
    First data & 932\\ \hline
     & 239\\ \hhline{|>{\arrayrulecolor{red}}->{\arrayrulecolor{black}}|-|}
     & 137\\ \hhline{|>{\arrayrulecolor{red}}->{\arrayrulecolor{black}}|-|}
    \multirow{-3}{*}{More data} & 319\\ \hline
    Last data & 132\\ \hline
  \end{tabular}

\end{document}

Result:

enter image description here

share|improve this answer
    
Never thought of that solution. It's indeed not the best solution but it works nonetheless :) So thanks! –  Didii Jul 30 '12 at 13:58
    
I've noticed that in there are very small white-ish lines in between the cells of the multirows - has anyone found a way to get rid of those? –  zje Dec 5 '13 at 5:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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