Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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{1}{tableShade}{white}
\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}
share|improve this question
3  
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
add comment

2 Answers

up vote 14 down vote accepted

It's easy:

\documentclass[xcolor=table]{beamer}

or

\documentclass[table]{beamer}

You can also use:

\PassOptionsToPackage{table}{xcolor}
\documentclass{beamer}
share|improve this answer
    
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
1  
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
add comment

You can also pass it as follows:

\documentclass[xcolor=table]{beamer}
share|improve this answer
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  Martin Scharrer Jul 27 '11 at 14:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.