Graphics, Figures & Tables\cellcolor colors over table rules

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sk
Posts: 8
Joined: Wed Sep 08, 2010 10:11 am

\cellcolor colors over table rules

Post by sk »

Hi everyone,

I use the command \cellcolor provided by the package colortbl to color some table cells using a gray scale. The problem is, even though I pute rules in the table using \cline, these are not show in some cells.

I attach a small example (.tex) together with the pdf file that ilustrates the problem.

Any hints on how to solve this are appreciated.
Attachments
example.zip
(18.09 KiB) Downloaded 237 times
Last edited by sk on Wed Sep 22, 2010 1:59 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

\cellcolor colors over table rules

Post by meho_r »

Don't use \cline, but \hhline from hhline package:

Code: Select all

\documentclass[a4paper, 11pt]{article}
\usepackage{colortbl}
\usepackage{hhline}
\usepackage{multirow}

\begin{document}

\begin{table}[!h]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline
Column1 &   Column2 &   1 &  2 &  3 &  4 &  5 &  6 &  7 &  8 &  9 &  10 & 11 \\ \hline
\multirow{2}{*}{Rows} 
& Row1    &  &   &   &  &  &  &  &  &  &  & \\ \cline{2-13}
& Row2 &  & &  &   &  &  &   &   &  &  & \\ \hline
\multirow{2}{*}{More rows}
& Row3 &   &   &   &   &   &   &   &   &   &   &   \\ \cline{2-13}
& Row4 &   &   &   &   &   &   &   &   &   &   &   \\ \hline
\end{tabular}
\caption{This table has all the rules...}
\end{table}

\begin{table}[!h]
\arrayrulecolor{blue}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline
\cellcolor[gray]{0.9} Column1 & \cellcolor[gray]{0.9} Column2 & \cellcolor[gray]{0.9} 1 & \cellcolor[gray]{0.9}2 & \cellcolor[gray]{0.9}3 & \cellcolor[gray]{0.9}4 & \cellcolor[gray]{0.9}5 & \cellcolor[gray]{0.9}6 & \cellcolor[gray]{0.9}7 & \cellcolor[gray]{0.9}8 &\cellcolor[gray]{0.9} 9 & \cellcolor[gray]{0.9}10 & \cellcolor[gray]{0.9}11 \\ \hline
\multirow{2}{*}{Rows} 
& Row1    &  & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} &  &  &  &  &  &  &  & \\ \hhline{~------------}
& Row2 &  & &  & \cellcolor[gray]{0.5} &  &  & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} &  &  & \\ \hline
\multirow{2}{*}{More rows}
& Row3    & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} \\ \hhline{|~|-|-|-|-|-|-|-|-|-|-|-|-|}
& Row4 & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} &  \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} & \cellcolor[gray]{0.5} &  & \cellcolor[gray]{0.5} \\ \hline
\end{tabular}
\caption{...but this one doesn't}
\end{table}

\end{document}
Take a look at hhline package documentation for more infos.
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

\cellcolor colors over table rules

Post by CrazyHorse »

sk wrote:Hi everyone,

I use the command \cellcolor provided by the package colortbl to color some table cells using a gray scale. The problem is, even though I pute rules in the table using \cline, these are not show in some cells.

I attach a small example (.tex) together with the pdf file that ilustrates the problem.

Any hints on how to solve this are appreciated.
it is only a problem with the viewer. Print it and compare
the output.

Herbert
sk
Posts: 8
Joined: Wed Sep 08, 2010 10:11 am

Re: \cellcolor colors over table rules

Post by sk »

I thought about the viewer issue but then I printed and not all of them are OK. For example, al the cells in rows 3 and 4 that are colored in both rows do not have a rule.

I will try the hhline package.

EDIT: It seems to be working fine with hhline, I will print and then I will update the post if everything is OK

EDIT2: Printed also looks good. Thanks
Post Reply