How to avoid cline overwride when using cellcolor?
2,616
With hhline
. B.t.w., don't nest your table
environment in center
, as it adds an unwanted supplementary vertical spacing. Use the directive \centering
instead.
\documentclass[a4paper,11pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{multirow, hhline}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hhline{*{7}{-}}
Days & 3 & 6 & 9 & 12 & 15 & 18 \\
\hhline{*{7}{:=}:}
\multirow{2}{*}{Project} & \multicolumn{4}{c|}{\cellcolor{yellow} 1} & & \\
\hhline{|~|------|}
& & & \multicolumn{4}{c|}{\cellcolor{yellow} 2} \\
\hhline{*{7}{-}}
\end{tabular}
\end{table}
\end{document}
Author by
Hohenstoffen
Fluid mechanician, fluid dynamician, applied mathematician, theoretical physicist, mechanical engineer.
Updated on August 01, 2022Comments
-
Hohenstoffen over 1 year
The cline between the colored cells 1 and 2 in the example below has been overridden by the cellcolor command. I was wondering whether there exists a way to make the line separating these two cells on top of the yellow color. Any help is highly appreciated.
Thanks
Hartmut Helmut
\documentclass[a4paper,11pt]{article} \usepackage[utf8x]{inputenc} \usepackage[english]{babel} \usepackage[usenames,dvipsnames,svgnames,table]{xcolor} \usepackage{multirow} \begin{document} \begin{center} \begin{table} \begin{tabular}{|c|c|c|c|c|c|c|}\hline Days & 3 & 6 & 9 & 12 & 15 & 18 \\ \hline\hline \multirow{2}{*}{Project} & \multicolumn{4}{c|}{\cellcolor{yellow} 1} & & \\ \cline{2-7} & & & \multicolumn{4}{c|}{\cellcolor{yellow} 2} \\ \hline \end{tabular} \end{table} \end{center} \end{document}
-
David Carlisle about 6 yearsplease see the
colortbl
package documentation.\cline
is explicitly not supported. You could use\hhline
from thehhline
package instead. -
Hohenstoffen about 6 years@Schweinebacke The question you referred to deals with \columncolor while here I have cellcolor
-
David Carlisle about 6 years@HartmutHelmut these are the same thing (more or less)
-