# [Tex/LaTex] Specify starting row number for \rowcolors from colortbl package

colortbltables

In the following application of \rowcolors from the colortbl package, how can I specify the option to start the alternating color pattern from the 3rd row onwards? The first two rows in this case are part of the table heading, so I don't want the alternating background color to begin until the 3rd row down.

If you can, please refer to any relevant sections in the package manual – if it's there I couldn't seem to find it.

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage[x11names,dvipsnames,table]{xcolor} %for use in color links
\usepackage{colortbl}

\begin{document}
\rowcolors{1}{white}{Wheat1}
\begin{tabular}{l l l l l l}
\toprule
&   \multicolumn{4}{l}{Training data set}   &   Test data set\\
\cmidrule(l r){2-5} \cmidrule(l){6-6}
Method  &   MSE &   Var(Z)  &   $R^2$   &   RMSE    &   RMSE\\
\cmidrule(r){1 - 1} \cmidrule(l r){2-2} \cmidrule(l r){3-3} \cmidrule(l r){4-4} \cmidrule(l r){5-5} \cmidrule(l){6-6}
Global polynomial, order 1 & 1 & 2 & 3 & 4 & 5 \\
Global polynomial, order 3 & 6 & 7 & 8 & 9 & 10 \\
Global polynomial, order 5 & 11 & 12 & 13 & 14 & 15 \\
\bottomrule
\end{tabular}
\end{document}


The first mandatory argument of the \rowcolor command indicates the number of the first row which should be colored according to the color scheme given by the second and third mandatory arguments.

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage[table,x11names,dvipsnames,table]{xcolor}

\begin{document}

\rowcolors{5}{}{Wheat1}
\begin{tabular}{l l l l l l}
\toprule
&   \multicolumn{4}{l}{Training data set}   &   Test data set \\
\cmidrule(l r){2-5} \cmidrule(l){6-6}
Method  &   MSE &   Var(Z)  &   $R^2$   &   RMSE    &   RMSE\\
\cmidrule(r){1 - 1} \cmidrule(l r){2-2} \cmidrule(l r){3-3} \cmidrule(l r){4-4} \cmidrule(l r){5-5}   \cmidrule(l){6-6}
Global polynomial, order 1 & 1 & 2 & 3 & 4 & 5 \\
Global polynomial, order 3 & 6 & 7 & 8 & 9 & 10 \\
Global polynomial, order 5 & 11 & 12 & 13 & 14 & 15 \\
\bottomrule
\end{tabular}

\end{document}


EDIT2: or use \rowcolors{3}{Wheat1}{} in the above code if you want the first data row to have the Wheat1 color; in my code, the pattern will start having the first data row with white color.

The table option for xcolor loads the colortbl package, so there's no need to load it separately.

EDIT: information on the \rowcolor command can be found in the colortbl documentation and in Section 2.12 Color in tables in the xcolor documentation.