I am trying to color every other row in a longtable using the xcolor package with the table option as shown in this MWE (landscape and 17pt options are only used to shorten the MWE):
\documentclass[oneside,landscape,17pt]{memoir}
\usepackage{longtable}
\usepackage[table]{xcolor}
\definecolor{tableRows1}{gray}{0.9}
\definecolor{tableRows2}{gray}{0.4}
\begin{document}
\rowcolors{4}{tableRows1}{tableRows2}
\begin{longtable}{cc}
\hiderowcolors
\toprule
Column 1 & Column 2 \\
\midrule
\endfirsthead
%
\multicolumn{2}{c}{\textsl{Continued from previous page}}\\
\toprule
Column 1 & Column 2 \\
\midrule
\endhead
%
\bottomrule
\multicolumn{2}{c}{\textsl{Continued on next page}}
\endfoot
%
\bottomrule
\multicolumn{2}{c}{\textsl{Last foot}}
\endlastfoot
%
\showrowcolors
11 & 12 (\number\rownum) \\
21 & 22 \\
31 & 32 \\
41 & 42 \\
51 & 52 \\
11 & 12 \\
21 & 22 \\
31 & 32 \\
41 & 42 \\
51 & 52 \\
11 & 12 \\
21 & 22 \\
31 & 32 \\
41 & 42 \\
51 & 52 \\
11 & 12 \\
21 & 22 \\
31 & 32 \\
41 & 42 \\
51 & 52 \\
11 & 12 \\
21 & 22 \\
31 & 32 \\
41 & 42 \\
51 & 52 \\
\end{longtable}
\end{document}
As you can see, the coloring begins on the first line (not including the column descriptions) although I have specified it to begin at row 4 (\rowcolors{4}{tableRows1}{tableRows2}). Clearly some calculations are wrong(?) since row 1 is viewed as row 20 as shown in the parenthesis in row 1, column 2.
Why is that? And how do I change it to get the "correct" behavior?
Note: The offset roughly corresponds to the number of rows in the .tex-document from the beginning of the longtable to the first line of data, i.e. header and footer specification might be counted as part of the table. Commenting for instance the \multicolumn lines will reduce the number (20) on the first row.


\noalign{\global\rownum=1}\showrowcolors– Ulrike Fischer Mar 30 '17 at 13:08