1

This question already has an answer here:

If i color the text of a table cell, the text gets aligned wrong.

Without color:

enter image description here

With color:

Cell text colored

MWE:

\documentclass[10pt, handout]{beamer}

\usepackage{tabulary}
\usepackage{xcolor}

\begin{document}
    \begin{frame}{Test}
        \begin{tabulary}{\textwidth}{LLLL}
            test & test & test & test \\
            test & \color{red}test & test & test \\
        \end{tabulary}
    \end{frame}
\end{document}

I want to use it in a way like this:

\newcommand{\highlight}{\color{black}\cellcolor{red}}

\begin{tabulary}{\textwidth}{LLLL}
    test & test & test & test \\
    test & \highlight test & test & test \\
\end{tabulary}

marked as duplicate by Werner beamer Aug 25 '17 at 0:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Use \textcolor{red}{test} rather -- it works then. – user31729 Sep 5 '16 at 7:42
7

Either use \leavevmode or \textcolor

\documentclass[10pt, handout]{beamer}

\usepackage{tabulary}
\usepackage{xcolor}

\begin{document}
    \begin{frame}{Test}
        \begin{tabulary}{\textwidth}{LLLL}
            test & test & test & test \\
            test & \leavevmode\color{red}test & \textcolor{red}{test} & test \\
        \end{tabulary}
    \end{frame}
\end{document}

enter image description here

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