8

In beamer, I just want to highlight some cells with \alert, but when I use \alert it messes up my table layout. For some reason, I defined a special column type to have a more beautiful table. When I use \alert then it apparently messes up this layout and the cell falls out of place. I created a MWE that follows:

\documentclass{beamer}
\usepackage{xcolor,colortbl} 
\newcolumntype{L}[1]{>{\raggedleft\arraybackslash}p{#1}}
\begin{document}

\begin{frame}

\begin{tabular}{ll}
\alert{a} & b \\
c & d \\
\end{tabular}
\end{frame}

\begin{frame}
\begin{tabular}{L{1.3cm}L{1.3cm}}
\alert{a} & b \\
c & d \\
\end{tabular}
\end{frame}
\end{document}

Does anybody see a quick fix, so that I don't have to change my whole table and can still use \alert without killing the layout? That would make my life much easier.

2
  • 1
    I have the same problem. When I use \alert{} in a table then I get an extra white spave above the alerted text. Does anyone know why? Because I also change the font formatting (\bfseries in my case), the proposed solution by @Werner doesn't work for me. Commented Feb 20, 2017 at 21:22
  • It seems to have something todo with the \color{}macro. Using \textcolor{} as suggested by @Werner though works for me.
    – Arne
    Commented Sep 10, 2022 at 18:45

1 Answer 1

5

If it's just the colour change you're after, beamer's \alert uses red!95!black. However, this is also stored in the colour alert or beameralert. Below I defined \rawalert which sets just the font colour using \textcolor{beameralert}:

\documentclass{beamer}
\usepackage{xcolor,array}
\newcolumntype{L}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcommand{\rawalert}{\textcolor{beameralert}}
\begin{document}

\begin{frame}
  \begin{tabular}{ll}
    \alert{a} & b \\
    c & d \\
  \end{tabular}
\end{frame}

\begin{frame}
  \begin{tabular}{L{1.3cm}L{1.3cm}}
    \rawalert{a} & b \\
    c & d \\
  \end{tabular}
\end{frame}
\end{document}
4
  • The mandatory argument will be captured by \textcolor. If you wish, you could use \newcommand{\rawalert}[1]{\textcolor{beameralert}{#1}}, but the outcome will be the same.
    – Werner
    Commented Jun 23, 2014 at 18:35
  • Thanks a lot, that would fix the layout. On the other hand, I also liked to keep the possibility to overlay the highlights as it is possible with \alert<2> \begin{frame} \begin{tabular}{L{1.3cm}L{1.3cm}} \alert<2>{a} & b \\ c & d \\ \end{tabular} \end{frame}
    – Max M
    Commented Jun 24, 2014 at 9:42
  • 1
    @MaxM: An overlay-aware \rawalert is possible using this definition: \newcommand<>{\rawalert}{\textcolor#1{beameralert}}
    – Werner
    Commented Jun 25, 2014 at 5:27
  • 1
    I have the same problem. When I use \alert{} in a table then I get an extra white spave above the alerted text. Does anyone know why? Because I also change the font formatting (\bfseries in my case), the proposed solution by @Werner doesn't work for me. Apart from that, the solution would work for me :). Commented Feb 20, 2017 at 21:23

You must log in to answer this question.

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