Tuesday, August 19, 2008

Latex: change row color of table

An example here:

\usepackage[table]{xcolor}
(if you use pdflatex and/or beamer, perhaps you need to transit 'table' by
\documentclass[xcolor=table..]{beamer} or you will have an error like:
! LaTeX Error: Option clash for package xcolor.
)

\begin{table}
\centering
\rowcolors{2}{gray!10}{}\tiny
\begin{tabular}{c||cc|cc}\hline\hline
....
\end{tabular}
\caption{...}
\end{table}

2 comments:

AlfC said...

thank you for the post. The results are beautiful. Now, I have a problem, how do I restore the default colors after this.
This settings also affect the subsequent math environments "array" and "cases".

ilMartins said...

from the moment you write

\rowcolors{2}{gray!10}{}

in all tables, arrays and else you'll see alternate colors for the rows, but it's quite the command

\setlanguage{..}

so, if you want to came back and have always again all rows white coloured, after the table you have to color write the command

\rowcolors{2}{}{}

Locations of visitors to this page