[Tex/LaTex] Table with different colors removes vertical and horizontal lines

colortables

I have a table in my documentation, where i'm switching the rowcolor between white(default) and gray. Those rows, where the color is changed with \rowcolor{gray}, disabling the horizontal and vertical lines?

\begin{table}[h]
\begin{tabular}{|l|p{7cm}|}
    \hline  
    \rowcolor{Blackgray}
    \textcolor{white}{\textit{Column 1}}                &       \textcolor{white}{\textit{Column 2}}                        \\      \hline 
    Fooo -- Bar                                         &       Some text here with enum:
                                                                \begin{itemize}
                                                                    \item Item1
                                                                    \item Item2
                                                                    \item ...
                                                                \end{itemize}                                               \\      \hline
    \rowcolor{Gray} 
    Foo -- Baar                                         &       Some text here....                                          \\      \hline
    Fooo -- Baaaar                                      &       Some other text here                                        \\      \hline
    \rowcolor{Gray}
    Baar -- FOOO                                        &       Nope
                                                                \begin{itemize}
                                                                    \item Item1
                                                                \end{itemize}                                               \\      \hline
\end{tabular} 
\end{table}

enter image description here

What is wrong with my latex? why are there no vertical and horizontal lines? What should i include in my latex?

Best Answer

This happens because colortbl draws the rows over the columns.

Adopt this trick.

Add the following lines in your preamble:

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@classz}
  {\CT@row@color}
  {\oldCT@column@color}
  {}
  {}
\patchcmd{\@classz}
  {\CT@column@color}
  {\CT@row@color}
  {}
  {}
\patchcmd{\@classz}
  {\oldCT@column@color}
  {\CT@column@color}
  {}
  {}
\makeatother

MWE (I've changed your custom colors)

\documentclass[10pt,a4paper]{report}
\usepackage{colortbl}
\usepackage{xcolor}

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@classz}
  {\CT@row@color}
  {\oldCT@column@color}
  {}
  {}
\patchcmd{\@classz}
  {\CT@column@color}
  {\CT@row@color}
  {}
  {}
\patchcmd{\@classz}
  {\oldCT@column@color}
  {\CT@column@color}
  {}
  {}
\makeatother

\begin{document}

\begin{table}[h]
\begin{tabular}{|l|p{7cm}|}
    \hline
    \rowcolor{gray}
    \textcolor{white}{\textit{Column 1}}                &       \textcolor{white}{\textit{Column 2}}                        \\      \hline
    Fooo -- Bar                                         &       Some text here with enum:
                                                                \begin{itemize}
                                                                    \item Item1
                                                                    \item Item2
                                                                    \item ...
                                                                \end{itemize}                                               \\      \hline
    \rowcolor{lightgray}
    Foo -- Baar                                         &       Some text here....                                          \\      \hline
    Fooo -- Baaaar                                      &       Some other text here                                        \\      \hline
    \rowcolor{lightgray}
    Baar -- FOOO                                        &       Nope
                                                                \begin{itemize}
                                                                    \item Item1
                                                                \end{itemize}                                               \\      \hline
\end{tabular}
\end{table}

\end{document} 

Output:

enter image description here