I've encountered a weird problem whereby use of \hhline causes \rowcolors to mess up. It is like the \hhline is itself treated as a row (which is then 'coloured')
So, if I have \rowcolors{1}{white}{gray} before a tabular, every second row should be grey. And this is indeed what happens without any \hhlines (first table in MWE). However, if I have an \hhline after the second row the following row is unexpectedly grey (2nd table in MWE) and if I have an \hhline after the third row the following row is unexpectedly white.
I've tested barious permutations of this with different combinations of \hhline and numbers of rows, and the best understanding of the problem I can come up with is that \hhline is somehow treated like its own row which is then "coloured". (But you see no effect because \hhline isn't actually a row, I think...) So if you use \hhline for every row, none will be coloured.
Not sure if there's anything obvious I'm missing.
Code: Select all
\documentclass[a4paper,12pt]{article}
\usepackage{hhline}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}\rowcolors{1}{white}{gray} %coloured as I expect and want
\begin{tabular}{llll}
1&2&3&4\\ %white
1&2&3&4\\ %grey
1&2&3&4\\ %white
1&2&3&4\\ %grey
\end{tabular}
\end{table}
\begin{table}\rowcolors{1}{white}{gray} %third row unepextedly grey, final row white
\begin{tabular}{llll}
1&2&3&4\\ %white
1&2&3&4\\ \hhline{----} %grey
1&2&3&4\\ %grey
1&2&3&4\\ %white
\end{tabular}
\end{table}
\begin{table}\rowcolors{1}{white}{gray} %final row not grey as expected
\begin{tabular}{llll}
1&2&3&4\\ %gwhite
1&2&3&4\\ %grey
1&2&3&4\\ \hhline{----} %white
1&2&3&4\\ %white
\end{tabular}
\end{table}
\end{document}