0

I'm trying to colorize lines in a longtable, which is working except it is colorizing also the caption, like this -

\documentclass[a4paper,12pt]{report}
\usepackage[table,hyperref,dvipsnames]{xcolor}

\rowcolors{2}{green!25}{} 
\begin{longtable}{| p{.3\textwidth}| p{.7\textwidth}|}
\hline
cell one & cell two \\ \hline
cell three & cell four \\ \hline
cell five & cell six \\ \hline
cell seven & cell eight \\
\hline
\caption{Just a test table}
\end{longtable}

This always colorizes the caption line if there is an odd number of lines. This is in emacs 24.5.50.1, and utilising auctex in debian 8.

How can I get it so that the caption is always uncolored please?

4
  • See the second part of the answer to this question. It fixes your problem (duplicate): How to apply alternate row coloring in a longtable in LyX?
    – Alenanno
    May 7 '15 at 15:54
  • In other words, you should add the cell colour definition in the caption, like \caption{\cellcolor{white} Just a test table}.
    – Alenanno
    May 7 '15 at 15:57
  • I'd looked at the reference quoted before but totally missed the \cellcolor{white} part, and that does solve the problem, although it does need several passes or builds. Thanks.
    – boudiccas
    May 7 '15 at 17:48
  • Several passes? Weird, I don't know why that is the case. It took me one. But glad it helped! :D
    – Alenanno
    May 7 '15 at 17:51

Browse other questions tagged or ask your own question.