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.

I'm trying to make a beamer slide containing a table with the text in a row styled in a different color. However, the row's height increases when colored, as opposed to the default. The same problem occurs if I use the \rowfont command. How do I correct this?

\PassOptionsToPackage{table}{xcolor}
\documentclass[compress]{beamer}

\begin{document}
\begin{frame}
    Example 1
    \rowcolors{1}{gray!30}{blue!30}
    \begin{tabular}{|p{0.5\textwidth}|}
        \hline
        \color{blue}{Foo} \\
        Bar\\
        Baz\\
        \hline
    \end{tabular}\\[1in]

    Example 2
    \rowcolors{1}{gray!30}{blue!30}
    \begin{tabular}{|p{0.5\textwidth}|}
        \hline
        Foo \\
        Bar\\
        Baz\\
        \hline
    \end{tabular}
\end{frame}
\end{document}

enter image description here

I want the table to look like "Example 2", but with the row text colored as in "Example 1".

share|improve this question
1  
Does \leavevmode (before or after \color) help? I remember a similar case. –  Raphael Oct 14 '13 at 7:29
1  
See the footnote on page 5 of texdoc grfguide (Using textcolor or putting \leavevmode or mbox{} before \color will fix it. (Sorry, it's not my fault:) –  David Carlisle Oct 14 '13 at 10:18
    
@DavidCarlisle This comment was difficult to find. It deserves to be more than a comment. I have scratched my head the whole day, trying to solve a similar problem. –  Sveinung Nov 6 at 18:34

1 Answer 1

up vote 8 down vote accepted

Use textcolor:

\PassOptionsToPackage{table}{xcolor}
\documentclass[compress]{beamer}

\begin{document}
\begin{frame}

    Example 1
    \rowcolors{1}{gray!30}{blue!30}
    \begin{tabular}{|p{0.5\textwidth}|}
        \hline
        \textcolor{blue}{Foo} \\
        Bar\\
        Baz\\
        \hline
    \end{tabular}\\[1in]

    Example 2
    \rowcolors{1}{gray!30}{blue!30}
    \begin{tabular}{|p{0.5\textwidth}|}
        \hline
        Foo \\
        Bar\\
        Baz\\
        \hline
    \end{tabular}
\end{frame}
\end{document}

enter image description here

share|improve this answer

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.