19

As the graphic and MWE below show, some of colored my table cells are obscured the cell colors. I'd appreciate help fixing this.

Table with colored cells

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[table]{xcolor}

\makeatletter
\providecommand{\tabularnewline}{\\}
\makeatother

\usepackage{babel}
\begin{document}
\begin{tabular}{c|c|c|c|cc|}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{A} & \multicolumn{1}{c}{B} & \multicolumn{1}{c}{C} & D & \multicolumn{1}{c}{E}\tabularnewline
\cline{2-6} 
a & \cellcolor{blue!25} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} &  & \cellcolor{red!25} \tabularnewline
\cline{2-3} 
b &  &  & \multicolumn{1}{c}{} &  & \tabularnewline
\cline{2-4} 
c &  &  &  &  & \tabularnewline
\cline{2-5} 
d &  &  &  & \multicolumn{1}{c|}{} & \tabularnewline
\cline{2-6} 
e &  & \cellcolor{green!25} &  & \multicolumn{1}{c|}{} & \tabularnewline
\cline{2-6} 
\end{tabular}
\end{document}
20

You can use hhline here which simply adds vertical space and doesn’t get over-drawn by \cellcolor.

Code

\documentclass{standalone}
\usepackage[table]{xcolor}
\usepackage{hhline}
\begin{document}
\begin{tabular}{c|c|c|c|cc|}
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{A} & \multicolumn{1}{c}{B} & \multicolumn{1}{c}{C} &           D           & \multicolumn{1}{c}{E} \tabularnewline \hhline{~|*{5}{-}}
             a           &  \cellcolor{blue!25}  & \multicolumn{1}{c}{}  & \multicolumn{1}{c}{}  &                       &  \cellcolor{red!25}   \tabularnewline \cline{2-3}
             b           &                       &                       & \multicolumn{1}{c}{}  &                       &  \tabularnewline \cline{2-4}
             c           &                       &                       &                       &                       &  \tabularnewline \cline{2-5}
             d           &                       &                       &                       & \multicolumn{1}{c|}{} &  \tabularnewline \hhline{~|*5-}
             e           &                       & \cellcolor{green!25}  &                       & \multicolumn{1}{c|}{} &  \tabularnewline \hhline{~|*5-}
\end{tabular}
\end{document}

Output

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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