2

I have a table with several values witch I need to highlight during a presentation. I used tcolorbox to distinguish these data from the rest and colorbox to the highlight.

The problem is the text keeps wobbling around. As the first text gets highlighted it moves right and the second line moves down. Also there's an extra line in the tcolorbox environment which only disappears at the end.

MWE

\documentclass{beamer}
\mode<presentation>
\usepackage{fixltx2e} 
\usepackage{soul}               % to striketrhourhg text
\usepackage{tcolorbox}          % fancy colored boxes


\begin{document}
\begin{frame}[c,fragile]

    \begin{tcolorbox}[colback=lightgray,
        colframe=white,
        rounded corners=all]
        \begin{tabular}{ l l }
            \only<1>{\(a=7\)  & \(cI=8\) \\}
            \only<2->{\(a=7\) & \colorbox{yellow}{\(cI=8\)} \\}       

            \only<-3>{\(b=2\) & \(dS=3\)\\}
            \only<4>{\(b=2\) & \colorbox{yellow}{\(dS=3\)} \\}
            \only<5->{\colorbox{yellow}{\(b=2\)} & \(dS=3\) \\}
        \end{tabular}
    \end{tcolorbox}

\end{frame}
\end{document}

Wobbling text

3

First of all, let's say your are asking a question about

  • how to make \alert works like \colorbox instead of \textcolor; and
  • how to stabilize these \colorboxes?

The first question is simple since Beamer provide \newcommand<>. Now you can define a \boxalert<2,4>{} working just like \alert<2,4>{}.

\newcommand<>\boxalert[1]{
    \alt#2{\colorbox{yellow}{$#1$}}{$#1$}

For the second, make sure your contents are put inside a \colorbox all the time:

\newcommand<>\boxalert[1]{
    \alt#2{\colorbox{yellow}{$#1$}}{\colorbox{lightgray}{$#1$}}

and the following code gives stable result:

\begin{frame}[fragile]
    \begin{tcolorbox}[colback=lightgray,colframe=white,rounded corners=all]
        \begin{tabular}{ll}
            \boxalert<2,4,6,8>{a=7} & \boxalert<3,4,7,8>{cI=8} \\
            \boxalert<5,6,7,8>{b=2} & \boxalert<      0>{dS=3} \\
        \end{tabular}
    \end{tcolorbox}
\end{frame}

If pseudo-transparent background is not desired, tcolorbox, which seems to be used by you already, gives a way to define a real transparent background:

\renewcommand<>\boxalert[1]{
    \alt#2{\tcbox[colback=yellow,frame empty]{$#1$}}{\tcbox[colback=red,opacityback=0,frame empty]{$#1$}}
}

Note that the spacing is inconsistent. I guess that is inevitable while having colorbox, beamercolorbox, and tcolorbox in the same document.

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.