TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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

marked as duplicate by Papiro, Svend Tveskæg, Andrew Swann, darthbith, barbara beeton Mar 30 at 19:52

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.

up vote 8 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
2  
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

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