|
|
\cellcolor covers vertical lines
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}
|
|
0
|
|
|
|
Reply
|
ahallam
|
3/28/2011 6:58:28 PM |
|
Le 28/03/2011 20:58, ahallam@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.
|
|
0
|
|
|
|
Reply
|
gouailles (1705)
|
3/28/2011 9:17:38 PM
|
|
On Mar 28, 4:17=A0pm, GL <gouail...@gmail.com> wrote:
> Le 28/03/2011 20:58, ahal...@iastate.edu a =E9crit :
>
> > I have a table with colored cells. =A0They cover the vertical lines
> > within the cells. =A0See 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. =A0I 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 !
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D> fully buggy !
>
> \columncolor{color}[left overhang]
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0[right overhang]
>
> overhang is in place of \tabcolsep. Very usefull ! That is if you change
> \tabcolsep, you have to change the overhangs parameters !!
>
> \tabcolsep=3D6pt so here we put overhang=3D5pt 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
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\columncolor{background}[5=
pt][5pt]%
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \noindent\color{foregroun=
d}} m{#1mm}}
> Well: if you want to change the color just say :
> =A0 =A0 \xglobal\colorlet{foreground}{....}
> =A0 =A0 \xglobal\colorlet{background}{....}
>
> Then the preamble collaspes into:
>
> \begin{tabular}{>{\columncolor{DarkBlue}\noindent\color{white}}M{30}
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*5{M{25} |}}
>
> And colortbl is buggy (see the example)
> And \hhline is crap ! | =A0does not follow \arrayrulewidth for example
> And \cellcolor does not provide the overhang parameters !
>
> With tabu this is :
>
> \tabusetup* {reset,linesep=3D0pt,everyrow=3D\noalign{\vskip1mm},
> =A0 =A0 =A0 =A0 =A0 =A0 =A0overhang=3D-1pt }
>
> \begin{tabu} { X [ ^white _DodgerBlue] | *5X[ .9 l LightGrey ] }
> \rowfont{\cellcolor{ ^DodgerBlue _white }}
> \blankcell =A0&\multicolumn5c{\Large \bfseries
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Clean Energy T=
echnologies and Components}
> \\ \tabucline{2-}\noalign{\vskip1mm}
> \rowfont{\cellcolor {^white _blue }}\blankcell
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&Solar Cel=
ls &Wind Turbines
> &\multicolumn2c{Vehicles} &Lighting
> \\
> MATERIAL \rowfont{\cellcolor{ ^DarkBlue _white } =A0}
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&PV films =
=A0 =A0&Magnets =A0 =A0 =A0 &Magnets
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 &Batteries &Phosphors
> \\
> \cellcolor{blue} Cerium =A0 & & & =A0& & =A0 =A0 =A0 =A0 =A0\\
> Indium =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0& =A0& & & & =A0 =A0 =A0 =
=A0 =A0\\
> Gallium =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 & =A0& & & &
> \\ \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]\noin=
dent\color{foreground}}
> m{#1mm}}
> \colorlet{background}{white}
> \colorlet{foreground}{black}
> \noindent
> \begin{tabular} { >{\columncolor{DarkBlue}\noindent\color{white}} M{30}
> =A0 *5{M{25} |} }
> \cellcolor{white} =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 & \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 =A0\\
> \cellcolor{DarkBlue}
> MATERIAL
> \xglobal\colorlet{background}{white}
> \xglobal\colorlet{foreground}{DarkBlue}
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &PV films =A0 =A0&Magnets =A0 =A0 =A0=
&Magnets
> &Batteries &Phosphors \\ \hhline{|~:-|-|-|-|-|}
> \xglobal\colorlet{background}{LightGrey}
> \cellcolor{blue}\noindent\color{white}
> Cerium =A0 =A0 =A0 =A0 =A0& =A0 =A0 =A0 =A0 =A0 =A0& =A0 =A0 =A0 =A0 =A0 =
=A0 =A0& =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &
> =A0 =A0 =A0 =A0 =A0 & =A0 =A0 =A0 =A0 =A0\\ \hhline{|~:-|-|-|-|-|}
> \cellcolor{DarkBlue}\noindent\color{white}
> Indium =A0 =A0 =A0 =A0 =A0& =A0 =A0 =A0 =A0 =A0 =A0& =A0 =A0 =A0 =A0 =A0 =
=A0 =A0& =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &
> =A0 =A0 =A0 =A0 =A0 & =A0 =A0 =A0 =A0 =A0\\ \hhline{|~:-|-|-|-|-|}
> \cellcolor{DarkBlue}\noindent\color{white}
> Gallium =A0 =A0 =A0 =A0 & =A0 =A0 =A0 =A0 =A0 =A0& =A0 =A0 =A0 =A0 =A0 =
=A0 =A0& =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &
> =A0 =A0 =A0 =A0 =A0 & =A0 =A0 =A0 =A0 =A0\\ \hhline{|~:-|-|-|-|-|}
> Gallium =A0 =A0 =A0 =A0 & =A0 =A0 =A0 =A0 =A0 =A0& =A0 =A0 =A0 =A0 =A0 =
=A0 =A0& =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &
> =A0 =A0 =A0 =A0 =A0 & =A0 =A0 =A0 =A0 =A0\\ \hhline{|~:-|-|-|-|-|}
> \end{tabular}
>
> Yours sincerely.
Thanks, The second one works great for me.
Arne
|
|
0
|
|
|
|
Reply
|
ahallam (88)
|
3/29/2011 6:09:24 PM
|
|
|
2 Replies
538 Views
(page loaded in 0.145 seconds)
Similiar Articles:7/21/2012 9:59:55 PM
|
|
|
|
|
|
|
|
|