Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\cellcolor covers vertical lines

425 views
Skip to first unread message

aha...@iastate.edu

unread,
Mar 28, 2011, 2:58:28 PM3/28/11
to aha...@iastate.edu
I have a table with colored cells. They cover the vertical lines
within the cells. See code below.
If there was not a difference in the spacing between the cells and the
coloring, I would not see any of the vertical lines. I am not sure
what to do.

Ideas?


\documentclass{article}
\usepackage[svgnames,table]{xcolor}
\usepackage{array,hhline}

\usepackage[lmargin=1.0in, rmargin=1.0in, tmargin=1in, bmargin=1in]
{geometry}

\begin{document}


\begin{center}
\begin{tabular}%
{>{\raggedright}m{3cm}>{\raggedright}m{2.5cm}>{\raggedright}m{2.5cm}%
>{\raggedright}m{2.5cm}>{\raggedright }m{2.5cm}>{\raggedright }m{2.5cm}|}
\multicolumn{1}{c}{}&\multicolumn{5}{c}{\Large \bfseries
{\color{DodgerBlue} Clean Energy
Technologies and Components}} \tabularnewline
&\cellcolor{Blue}{\color{white} Solar Cells}& \cellcolor{Blue}
{\color{white} Wind Turbines} & %
\multicolumn{2}{c}{\cellcolor{Blue}{\color{white} Vehicles}} &
\cellcolor{Blue}{\color{white}
Lighting} \tabularnewline
\cellcolor{DarkBlue}{\color{white} MATERIAL}&{\color{DarkBlue} PV
films}&
{\color{DarkBlue} Magnets} & {\color{DarkBlue} Magnets} &
{\color{DarkBlue} Batteries} &
{\color{DarkBlue} Phosphors} \tabularnewline \hhline{|~:-|-|-|-|-|}
\cellcolor{Blue}{\color{white} Cerium}&\cellcolor{LightGrey}&
\cellcolor{LightGrey}&
\cellcolor{LightGrey}&\cellcolor{LightGrey} &\cellcolor{LightGrey}
\tabularnewline \hhline{|~:-|-|-|-|-|}
\cellcolor{DarkBlue}{\color{white} Indium}&\cellcolor{LightGrey}&
\cellcolor{LightGrey}&
\cellcolor{LightGrey}&\cellcolor{LightGrey} &\cellcolor{LightGrey}
\tabularnewline \hhline{|~:-|-|-|-|-|}
\cellcolor{DarkBlue}{\color{white} Gallium}&\cellcolor{LightGrey}&
\cellcolor{LightGrey}&
\cellcolor{LightGrey}&\cellcolor{LightGrey} &\cellcolor{LightGrey}
\tabularnewline \hhline{|~:-|-|-|-|-|}
\end{tabular}
\end{center}

\end{document}

GL

unread,
Mar 28, 2011, 5:17:38 PM3/28/11
to
Le 28/03/2011 20:58, aha...@iastate.edu a écrit :
> I have a table with colored cells. They cover the vertical lines
> within the cells. See code below.
> If there was not a difference in the spacing between the cells and the
> coloring, I would not see any of the vertical lines. I am not sure
> what to do.
>
> Ideas?

First refer to colortbl documentation.
Second it's David Carlisle's job: and David does not like colors !
=> fully buggy !

\columncolor{color}[left overhang]
[right overhang]

overhang is in place of \tabcolsep. Very usefull ! That is if you change
\tabcolsep, you have to change the overhangs parameters !!

\tabcolsep=6pt so here we put overhang=5pt to reduce the area by 1pt.
In tabu package we will say [-1pt] ;-) ie \tabcolsep -1pt !

\tabularnewline is unreadable: use \\ and \arraybackslash

\newcolumntype M[1]{>{\raggedright\arraybackslash
\columncolor{background}[5pt][5pt]%
\noindent\color{foreground}} m{#1mm}}
Well: if you want to change the color just say :
\xglobal\colorlet{foreground}{....}
\xglobal\colorlet{background}{....}

Then the preamble collaspes into:

\begin{tabular}{>{\columncolor{DarkBlue}\noindent\color{white}}M{30}
*5{M{25} |}}

And colortbl is buggy (see the example)
And \hhline is crap ! | does not follow \arrayrulewidth for example
And \cellcolor does not provide the overhang parameters !

With tabu this is :

\tabusetup* {reset,linesep=0pt,everyrow=\noalign{\vskip1mm},
overhang=-1pt }

\begin{tabu} { X [ ^white _DodgerBlue] | *5X[ .9 l LightGrey ] }
\rowfont{\cellcolor{ ^DodgerBlue _white }}
\blankcell &\multicolumn5c{\Large \bfseries


Clean Energy Technologies and Components}

\\ \tabucline{2-}\noalign{\vskip1mm}
\rowfont{\cellcolor {^white _blue }}\blankcell
&Solar Cells &Wind Turbines
&\multicolumn2c{Vehicles} &Lighting
\\
MATERIAL \rowfont{\cellcolor{ ^DarkBlue _white } }
&PV films &Magnets &Magnets
&Batteries &Phosphors
\\
\cellcolor{blue} Cerium & & & & & \\
Indium & & & & & \\
Gallium & & & & &
\\ \hline
\end{tabu}

But I have to finish the implementation ;-)


With tabular, a possible solution with your beloved \hhline ;-)

\newcolumntype
M[1]{>{\raggedright\arraybackslash\columncolor{background}[5pt][5pt]\noindent\color{foreground}}
m{#1mm}}
\colorlet{background}{white}
\colorlet{foreground}{black}
\noindent
\begin{tabular} { >{\columncolor{DarkBlue}\noindent\color{white}} M{30}
*5{M{25} |} }
\cellcolor{white} & \multicolumn5c{\Large
\bfseries{\color{DodgerBlue} Clean Energy Technologies and Components}} \\
\xglobal\colorlet{background}{blue}
\xglobal\colorlet{foreground}{white}
\cellcolor{white} &Solar Cells &Wind Turbines
&\multicolumn2c{\cellcolor{background}\noindent\color{foreground}Vehicles}
& Lighting \\
\cellcolor{DarkBlue}
MATERIAL
\xglobal\colorlet{background}{white}
\xglobal\colorlet{foreground}{DarkBlue}
&PV films &Magnets &Magnets
&Batteries &Phosphors \\ \hhline{|~:-|-|-|-|-|}
\xglobal\colorlet{background}{LightGrey}
\cellcolor{blue}\noindent\color{white}
Cerium & & & &
& \\ \hhline{|~:-|-|-|-|-|}
\cellcolor{DarkBlue}\noindent\color{white}
Indium & & & &
& \\ \hhline{|~:-|-|-|-|-|}
\cellcolor{DarkBlue}\noindent\color{white}
Gallium & & & &
& \\ \hhline{|~:-|-|-|-|-|}
Gallium & & & &
& \\ \hhline{|~:-|-|-|-|-|}
\end{tabular}

Yours sincerely.


aha...@iastate.edu

unread,
Mar 29, 2011, 2:09:24 PM3/29/11
to
On Mar 28, 4:17 pm, GL <gouail...@gmail.com> wrote:

Thanks, The second one works great for me.


Arne

0 new messages