# Use xcolor for colored tables in a beamer slide

How can I use a table with alternately colored rows like this in a beamer slide? There seems to be a conflict with beamer and xcolor. I am using LyX too, bonus marks for something that works well in LyX.

\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{center}
\rowcolors[]{2}{blue!20}{blue!10}
\begin{tabular}{ r p{4cm} l}\hline
\textbf{col1} &\textbf{col2} &\textbf{col3}\\\hline
& & \\
& & \\
& & \\
& & \\
& & \\
& & \\
\end{tabular}

\end{center}

\end{document}

• The problem is that that beamer already loads xcolor, but without the table option. LaTeX generates an error if a package is loaded twice with different options. So you have to get the first instance to be loaded with the table option. – Caramdir Jan 12 '11 at 4:29

It's easy:

\documentclass[xcolor=table]{beamer}


or

\documentclass[table]{beamer}


You can also use:

\PassOptionsToPackage{table}{xcolor}
\documentclass{beamer}

• I think the first option works in Lyx. You need to go to the toolbar and select Document -> Settings -> select "Document Class" from the sidebar -> Go to the "Custom" box in the "Class Options" section -> enter "table" – denilw Jan 12 '11 at 4:52
• I face the same problem, in LyX, when both LyX' Track Changes function is active as well as the Show changes in output option. Entering the table or xcolor=table option does not help. Neither does the command \PassOptionsToPackage{table}{xcolor}. Any ideas? – Nikos Alexandris Jun 22 '12 at 15:00
• It works using table as a document class option and, of course, erasing (if any) the \usepackage[table]{xcolor} entry from the Preamble. It does not work using xcolor=table. – Nikos Alexandris Jun 23 '12 at 1:48

You can also pass it as follows:

\documentclass[xcolor=table]{beamer}