2

This question already has an answer here:

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}

marked as duplicate by Schweinebacke, Bordaigorl, TeXnician, David Carlisle tables Sep 5 '17 at 9:48

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.

  • 1
    please see the colortbl package documentation. \cline is explicitly not supported. You could use \hhline from the hhline package instead. – David Carlisle Sep 5 '17 at 8:40
  • @Schweinebacke The question you referred to deals with \columncolor while here I have cellcolor – Volterra Sep 5 '17 at 9:09
  • 1
    @HartmutHelmut these are the same thing (more or less) – David Carlisle Sep 5 '17 at 9:47
3

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} 

enter image description here

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