4

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}
1
  • Use \textcolor{red}{test} rather -- it works then.
    – user31729
    Sep 5, 2016 at 7:42

1 Answer 1

10

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

2

Not the answer you're looking for? Browse other questions tagged .