[Tex/LaTex] \rowcolor and custom column separators

colorcolortbltables

When I use \rowcolor, custom separators between columns are not affected:

\documentclass{article}

\usepackage{xcolor}
\usepackage{colortbl}

\begin{document}
    \begin{tabular}{p{1cm}!{-}p{1cm}}
        \rowcolor{gray} foo & bar
    \end{tabular}
\end{document}

The - is rendered with white background, although the whole row should be gray. How can I fix that?

Best Answer

A couple of possibilities. Sorry the interface is rubbish, it's not entirely my fault.

enter image description here

\documentclass{article}

\usepackage{xcolor}
\usepackage{colortbl}

\begin{document}
    \begin{tabular}{p{1cm}!{-}p{1cm}}
        \rowcolor{gray} foo & bar
    \end{tabular}

\bigskip

    \begin{tabular}{p{1cm}!{-}p{1cm}}
        \rowcolor{gray}
        \multicolumn{1}{p{1cm}!{\fboxsep=0pt\colorbox{gray}{\strut-}}}{foo} & bar
    \end{tabular}


\bigskip

    \begin{tabular}{p{1cm}!{-}p{1cm}}
    \rowcolor{gray}
    \multicolumn{1}{>{\columncolor{gray}[\tabcolsep][15pt]}p{1cm}!{-}}{foo}& bar
    \end{tabular}

\end{document}