6

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".

3
  • 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 '14 at 18:34
8

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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