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.

I have a table which I want to fill with multiple colors, each cell possibly different from another. Which means, I can't make use of e.g. \columncolor (as in this post).

While the table without any colors looks just fine (code at the end): empty table

...the table with one or more filled cells overwrites the table grid. filled tables

So my question is: Is there a way to, for example, redraw the grid after filling the cells or something?


EDIT: added complete code instead of code fragments Relevant LaTeX code:

\documentclass[11pt]{article}

\usepackage{color}
\usepackage{colortbl}
\usepackage{multirow}

\newlength{\Oldarrayrulewidth}
% Cline redefining to add line thickness
\newcommand{\Cline}[2]{%
  \noalign{\global\setlength{\Oldarrayrulewidth}{\arrayrulewidth}}%
  \noalign{\global\setlength{\arrayrulewidth}{#1}}\cline{#2}%
  \noalign{\global\setlength{\arrayrulewidth}{\Oldarrayrulewidth}}
}


\definecolor{intnull}{RGB}{213,229,255}
\definecolor{inteins}{RGB}{128,179,255}
\definecolor{intzwei}{RGB}{42,127,255}
\definecolor{intdrei}{RGB}{0,85,212}
\definecolor{intvier}{RGB}{0,51,128}
\definecolor{intfunf}{RGB}{0,34,85}


\begin{document}
% Empty table
\begin{tabular}{*{5}{!{\vrule width 1.5pt}p{1.5cm}}!{\vrule width 1.5pt}l}
\centering 4 &
\centering 10 &
\centering 24 &
\centering 48 &
\centering 72 &\\ \Cline{1.5pt}{0-4}
 &  &  &  &  & Optic tectum \\ \Cline{1.5pt}{3-5}
 &  &  &  &  & Retina \\ \Cline{1.5pt}{3-5}
 &  &  &  &  & Myomeres \\ \Cline{1.5pt}{0-4}
 &  &  &  &  & Arches \\ \Cline{1.5pt}{0-4}
\end{tabular} \\

\hspace*{1cm}

% Partically filled table
\begin{tabular}{*{5}{!{\vrule width 1.5pt}p{1.5cm}}!{\vrule width 1.5pt}l}
\centering 4 &
\centering 10 &
\centering 24 &
\centering 48 &
\centering 72 &\\ \Cline{1.5pt}{0-4}
 & \cellcolor{intnull} &  & \cellcolor{intvier} &  & Optic tectum \\ \Cline{1.5pt}{3-5}
 & \cellcolor{intnull} &  & \cellcolor{intnull} &  & Retina \\ \Cline{1.5pt}{3-5}
 & \cellcolor{intnull} &  & \cellcolor{intdrei} &  & Myomeres \\ \Cline{1.5pt}{0-4}
 & \cellcolor{inteins} &  & \cellcolor{inteins} &  & Arches \\ \Cline{1.5pt}{0-4}
\end{tabular}

\end{document}
share|improve this question

2 Answers 2

up vote 7 down vote accepted

Please don't just post fragments of code that can not be run, always post complete small documents.

The fix should be exactly as in the other question. As documented colortbl is incompatible with \cline, you need to use \hhline instead. The fact that the cell backgrounds are different colours is irrelevant to the problem of \cline including negative spacing so that it comes under the colour.

share|improve this answer
    
This leads to new, but different problems: I read your documentation of the hhline package and used \hhline{*{2}{|~}*{3}{|-}|~|} instead of \Cline. Now I have white lines where no line should be. Using actual multirows has no different effect. –  Dennis Aug 2 '12 at 13:58
    
It might be better to solve this in a follow-up question –  Dennis Aug 2 '12 at 14:22

Just put the command \cellcolor[]{} inside brackets {} and it will not overwrite the table lines like this

\hline

{\cellcolor[gray]{.8}} Chapter & Title \\

\hline
share|improve this answer
    
Welcome to TeX.sx! If you indent lines by 4 spaces, they will be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  Peter Jansson May 3 '13 at 13:16
    
If you just use \hline and not \cline that is working perfect and is much easier implemented! I can not tick it as right answer as this is already done with the first answer. –  Gerlind Schubert Oct 24 '13 at 8: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.