I have a tabular that has altering background color (every second row is colored). Some cells use a separator character instead of a vertical line. The following code tries to implement this first using !{}
for the separator character and then @{}
:
\documentclass{article}
\usepackage{array}
\usepackage[table]{xcolor}
\newcommand{\dotsep}{\footnotesize\raisebox{0.2pt}{\bullet}}
\newcommand{\row}[6][]{
#1#2 & \centering #1#3 & \centering #1#4 & \centering #1#5 & #1#6
}
\newcommand{\testContent}{
\row{A}{B}{C}{D}{E} \\ \hline
\row[\cellcolor{gray!30}]{A}{B}{C}{D}{E} \\ \hline
\row{A}{B}{C}{D}{E} \\ \hline
\row[\cellcolor{gray!30}]{A}{B}{C}{D}{E}
}
\begin{document}
\begin{tabular}{p{1cm}|p{0.5cm}!{\dotsep}p{0.5cm}!{\dotsep}p{0.5cm}|p{1cm}}
\testContent
\end{tabular}
\begin{tabular}{p{1cm}|p{0.5cm}@{\dotsep}p{0.5cm}@{\dotsep}p{0.5cm}|p{1cm}}
\testContent
\end{tabular}
\end{document}
This is the result:
As you can see, if I use !{}
I do get the separator characters but they don't get the background color (as they are between the cells). If I use @{}
instead, they vanish if I set the background color.
I did use the tabu package with \rowcolor
in the past but it seems to be unmaintained and causes other problems.
How can I color the whole row including the separator characters while keeping them visible?