Tell me more ×
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.

I would like to highlight rows in tables, in rowwise, that is I would like to highlight row 1 in red, then make row 1 in black but row 2 in red, etc.

How can I manage to do so in Beamer?

share|improve this question
like this: tables-colouring-odd-even-mix? – cmhughes Aug 23 '12 at 4:11

1 Answer

up vote 3 down vote accepted

For a simple customized static row colouring :

\documentclass{beamer}
\usepackage{color, colortbl}
\definecolor{LRed}{rgb}{1,.8,.8}
\definecolor{MRed}{rgb}{1,.6,.6}
\definecolor{HRed}{rgb}{1,.2,.2}
\begin{document}
\begin{frame}
\begin{tabular}{ccc}
\rowcolor{LRed} a & b & c \\
                 a & b & c \\
\rowcolor{LRed} a & b & c \\
\rowcolor{MRed} a & b & c \\
\rowcolor{HRed} a & b & c \\
\rowcolor{MRed} a & b & c \\
\rowcolor{LRed} a & b & c \\
\rowcolor{MRed} a & b & c \\
\end{tabular}
\end{frame}
\end{document}

For overlays of odd/even coloring of the link of cmhughes or some more complex, see this MWE:

    \documentclass[xcolor=table]{beamer}

    \rowcolors{1}{gray!30}{gray!10}

    \makeatletter
    \def\rowcolor{\noalign{\ifnum0=`}\fi\bmr@rowcolor}
    \newcommand<>{\bmr@rowcolor}{%
        \alt#1%
            {\global\let\CT@do@color\CT@@do@color\@ifnextchar[\CT@rowa\CT@rowb}% 
            {\ifnum0=`{\fi}\@gooble@rowcolor}% 
    }

    \newcommand{\@gooble@rowcolor}[2][]{\@gooble@rowcolor@}
    \newcommand{\@gooble@rowcolor@}[1][]{\@gooble@rowcolor@@}
    \newcommand{\@gooble@rowcolor@@}[1][]{\ignorespaces}
    \makeatother

    \begin{document}
    \begin{frame}{The MWE}%

    \only<2>{\rowcolors{1}{blue!30}{blue!10}}
    \only<1,3>{\rowcolors{1}{gray!30}{gray!10}}

    \begin{center}
    \begin{tabular}{cc}
        A & B \\
        A & B \\
        A & B \\
        \rowcolor<4>{green} A & B \\
        \rowcolor<4,5>{yellow}A & B \\
        \rowcolor<4-6>{green}A & B \\
        \rowcolor<6>{red} A & B \\
        A & B \\

    \end{tabular}
    \end{center}

    \par    
    \visible<1>{Testing default row colouring ... \\}
    \visible<2,3>{Testing change of default colors ...\\}
    \visible<4-6>{Testing in-out of custom colors ...\\ (caution: The order of defaults colors can change)\\}

    \vfill
    \scriptsize{
Based of answer of Martin Scharrer
\url{http://tex.stackexchange.com/questions/18427/why-cant-i-wrap-rowcolor-in-only-beamer}}

    \end{frame}

    \end{document}
share|improve this answer
Thank you! I want to do the same thing for the cell color. \cellcolor<1>{red}, but it doesn't work. It seems I am not able to have the in-out effect of colors for cells. Please help! – user16739 Aug 23 '12 at 14:32
I think I have solved the above issue by using \only command. Thanks again! – user16739 Aug 23 '12 at 14:38

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.