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.


\usepackage{soul}               % to striketrhourhg text
\usepackage{tcolorbox}          % fancy colored boxes


        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\) \\}


Wobbling text


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>{}.


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


and the following code gives stable result:

    \begin{tcolorbox}[colback=lightgray,colframe=white,rounded corners=all]
            \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} \\

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:

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