# Removing rowcolors after long table

I am trying to have a long table in which every other data entry row is in gray. This I get easily by implementing:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{longtable}

\begin{document}

\rowcolors{2}{gray!30}{white}
\begin{longtable}{ccc}
\caption{My Long table}
\\ \hline
\rowcolor{white} first & second & third \\\hline
\rowcolor{white}
\multicolumn{3}{c}{\textit{...continued from last page}}
\\ \hline
\rowcolor{white} first & second & third \\
\endfoot
\endlastfoot
James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\ James&Jana&Julia \\
\end{longtable}


The problem is once I am done with this long table, every other table which I introduce afterward still keeps this feature, I can reset the row colors of course, but if I want to have a table in which every other column is colored, then it gets problematic. I know that it's mentioned in the documentation of xcolor package that it's not compatible with longtable, but is there any way to circumvent this? and if not is there any other easy way to color up the rows of my long table?

• Put \rowcolors{...}\begin{longtable} ... \end{longtable} in a group. B.t.w.., it seems that what does not work with longtable is the optional argument of\rowcolors, as I understand it. – Bernard Oct 12 '17 at 16:45
• @CarLaTeX: Done, milady! – Bernard Oct 13 '17 at 8:49
• You're welcome, la Sua Eccellenza! ;o) – Bernard Oct 13 '17 at 9:35

A simple solution is to put the table in a group:

\bgroup
\rowcolors{2}{gray!30}{white}
\begin{longtable}{ccc}
.............
.............
.............
\end{longtable}
\egroup

• i took liberty and add to your example line \rowcolors{2}{gray!30}{white}, which is to my opinion missed. – Zarko Oct 13 '17 at 8:56
• @Zarko: Thanks! I forgot to check the post (as often). As I had tested whether it did work by adding a second copy of the long table, I guess I pasted the second version, without \rowcolors… – Bernard Oct 13 '17 at 8:59