[Tex/LaTex] Tabular inside tcolorbox breaks beamer \pause

beamertablestcolorbox

Consider the following code:

\documentclass{beamer}
\usepackage{tcolorbox}

\begin{document}
\begin{frame}
  some text before
  \pause
  \begin{tcolorbox}
    \begin{tabular}{cc}
       cell1 & cell2\\\pause
       cell3 & cell4
    \end{tabular}
  \end{tcolorbox}
  \pause
  some text after
\end{frame}
\end{document}  

The expected result would be that "some text after" only appears on the fourth slide, but "some text after" is already visible on the second slide, then disappears on the third and then reappears in the fourth.

enter image description here

Any hint on what's going on?

Notes:

  • the same result occurs if the tabularx tcolorbox key is used instead of tabular
  • my actual workaround for this is to use \only or \uncover, but I'm more interested in the reason why this doesn't work.

edit: it seems that the tcolorbox environment interferes with the pause counter. If after the tcolorbox envirnoment you put

\setcounter{beamerpauses}{#}

where # is equal to the number of \pause issued before the tcolorbox environment everything works fine.

Uhm, actually that works only in a very specific scenario

Best Answer

You shouldn't use \pause inside tabular in the first place... as the beamer manual states:

This command does not work inside amsmath environments like align, since these do really wicked things.

Your main problem is independent from tabular, it's even independent from tcolorbox itself. It's bad interaction between setbeamercovered{invisible} mode of beamer and \endpgfpicture (tcolorbox uses TikZ/pgf as far as I know). The following example shows, that when there are more \pause-s inside the tikzpicture the interpreter fails to hide the upcoming pauses (note: even in another tikzpicture afterwards).

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}
  some text before
  \pause
  \begin{tikzpicture}
      \node at (0, 3) {Hello};
      \pause
      \node at (0, 2) {World};
      \pause
      \node at (0, 1) {and you};
      \pause
      \node at (0, 0) {and you};
  \end{tikzpicture}
  \pause
  some text after
\end{frame}

\end{document}

((As a workaround one could use \setbeamercovered{transparent=0}. But this still got issues with tabular... where you shouldn't use \pause... and some issues with the \tcolorbox coloring...))

So:

  • avoid using \pause inside tabular
  • avoid using \pause inside tikz therefore inside tcolorbox
  • avoid using any combination of the above
Related Question