1

I want to have a slide with some text in a box at the top, and on the next slide, this box - and the text within - become transparent to some opacity i specify. The tcolorbox is crucial to me because i want the colors and shape of the box to be consistent. I am currently trying out \uncover, but it doesn't make text transparent.

I also have another question, which is, how do I ensure that there's not too much space after tcolorbox? It doesn't show that much in this example, but I just want to be able to control the spacing between tcolorbox and the next line.

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage{tcolorbox}

\usepackage{verbatim}
\usepackage{tikz}
\usepackage{booktabs}
\usetikzlibrary{matrix,overlay-beamer-styles}

\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
%%%%%%%%%
\usetikzlibrary{calc}
\definecolor{pbblue}{HTML}{0A75A8}% color for the progress bar and the circle

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@rcircle % radius for the circle
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1pt
\progressbar@rcircle=2.5pt

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}
    \draw[pbblue!30,line width=\progressbar@pbht]
      (0pt, 0pt) -- ++ (\progressbar@pbwd,0pt);

    \filldraw[pbblue!30] %
      (\the\dimexpr\progressbar@tmpdim-\progressbar@rcircle\relax, .5\progressbar@pbht) circle (\progressbar@rcircle);

    \node[draw=pbblue!30,text width=3.5em,align=center,inner sep=1pt,
      text=pbblue!70,anchor=east] at (0,0) {\insertframenumber/\inserttotalframenumber};
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother
%%%%%%%%%%%
\begin{document}
\section{Proofs}
\begin{frame}[t]{title }
\setbeamercovered{transparent}%

\uncover<1>{\begin{tcolorbox}[hbox, left = 0.1 mm, right=0.1 mm, top = 0.4mm, bottom = 0.4mm]
Main idea
\end{tcolorbox}}

\uncover<2>{asdfasdf}
\end{frame}


\end{document}

1 Answer 1

3

tcolorbox comes with a lot of beamer support, see section 13 Beamer Support of manual v4.30. In particle, there is a hide key, which can be used here. One then can specify what "hide" means with

\tcbset{beamer hidden/.style={}}

Here is an example.

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage[skins]{tcolorbox}

\usepackage{verbatim}
\usepackage{tikz}
\usepackage{booktabs}
\usetikzlibrary{matrix,overlay-beamer-styles}

\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
%%%%%%%%%
\usetikzlibrary{calc}
\definecolor{pbblue}{HTML}{0A75A8}% color for the progress bar and the circle

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@rcircle % radius for the circle
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1pt
\progressbar@rcircle=2.5pt

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}
    \draw[pbblue!30,line width=\progressbar@pbht]
      (0pt, 0pt) -- ++ (\progressbar@pbwd,0pt);

    \filldraw[pbblue!30] %
      (\the\dimexpr\progressbar@tmpdim-\progressbar@rcircle\relax, .5\progressbar@pbht) circle (\progressbar@rcircle);

    \node[draw=pbblue!30,text width=3.5em,align=center,inner sep=1pt,
      text=pbblue!70,anchor=east] at (0,0) {\insertframenumber/\inserttotalframenumber};
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother
%%%%%%%%%%%
\tcbset{
beamer hidden/.style={opacityframe=0.1,opacityback=0.1,
opacitybacktitle=0.1,opacitytext=0.1}, }
\begin{document}
\section{Proofs}
\begin{frame}[t]{title }
\setbeamercovered{transparent}%

\begin{tcolorbox}[hbox, left = 0.1 mm, right=0.1 mm, 
top = 0.4mm, bottom = 0.4mm,hide=<2->]
Main idea
\end{tcolorbox}

\uncover<2>{asdfasdf}
\end{frame}
\end{document}

enter image description here

There are many more options to achieve similar results.

ADDENDUM: For the question in the comments you may use an overprint environment.

\documentclass{beamer}
\setbeamercovered{transparent}%
\begin{document}
\begin{frame}[t]
\frametitle{Without overprint}
\onslide<1>
Einstein said that \[E=mc^2\]
\onslide<2>
test

abc
\end{frame}

\begin{frame}[t]
\frametitle{With overprint}
\begin{overprint}
\onslide<1>
Einstein said that \[E=mc^2\]
\onslide<2>
test
\end{overprint}

abc
\end{frame}
\end{document}

enter image description here

6
  • Thank you SO much. I have one more question, if it's ok. I was trying to also achieve the feature, that i can replace a sentence in one slide with a tcolorbox in the next one (for example, by using \alt<>{}{}), but when i try that, it messes up the positioning (things jump around). Do you have a suggestion for that?
    – lazulikid
    Commented May 24, 2020 at 4:14
  • 1
    @lazulikid The answer is most likely yes, but the question is which result you expect. If the two objects have different dimensions, what should one do? Center the smaller one in a box that has the dimensions of the larger object? Are these the same texts which should be boxed on one slide and not boxed on another slide?
    – user194703
    Commented May 24, 2020 at 4:18
  • Sorry, should have clarified; what I mean is, one is a one-line sentence, the other is a tcolorbox with a one-line equation in it. The latter is slightly longer. Your suggested option (of centering the first sentence in an invisible box of the size of the second one) would work! They are not the same texts. To be more precise, the first is a sentence saying something in English; the second is a tcolorbox that has the math described by the sentence. But they do both fit in one line (and the equation is longer than the sentence).
    – lazulikid
    Commented May 24, 2020 at 4:22
  • 1
    @lazulikid This makes all sense but I would be really surprised if no one had done this before. That is, I probably can come up with a shaky code that does that but let's look first into the "literature" if there is not already a good solution for this. It seems to be such a generic problem. (Yet I would not know a post out of the top of my head. Please note also that one of the greatest beamer experts on this site has moved to this site. She would probably know out of the top of the head.) I'll to look first.
    – user194703
    Commented May 24, 2020 at 4:37
  • 1
    @lazulikid I think the overprint environment is what you are looking for. I added an example.
    – user194703
    Commented May 24, 2020 at 4:55

You must log in to answer this question.

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