1

How to define a new tcolorbox to achieve the following using \onslide but with out \onslide in every tcolorbox

Slide 1: Heading

Slide 2: Upper text

Slide 3: Lower text

\documentclass{beamer}
\usepackage{tcolorbox}

\begin{document}
\begin{frame}
\begin{tcolorbox}[title={Valency = ?},
colframe=green!50!black,
colback=green!50!black!10!white,
]
\onslide<2->{Hydrogen, H}
\tcblower
\onslide<3>{1}
\end{tcolorbox}
\end{frame}
\end{document}
  • 2
    Your document is not compilable... no document class, no packages – user31729 Feb 27 at 12:26
3

One way to achieve this, but with ugly 'jumping', depending on the needs, is to use the overlay statement only=<1->{...} with the relevant options to hide the lower box etc, and the segmentation line etc.

\documentclass{beamer}
\usepackage[most]{tcolorbox}

\begin{document}
\begin{frame}
\begin{tcolorbox}[only=<1->{title={Valency = ?}},only=<1-2>{lowerbox=ignored,segmentation hidden},
colframe=green!50!black,
colback=green!50!black!10!white,
]
\onslide<2->{Hydrogen, H}
\onslide<3->{%
\tcblower
1}
\end{tcolorbox}
\end{frame}
\end{document}

With a wrapper command:

\documentclass{beamer}
\usepackage[most]{tcolorbox}

\NewDocumentCommand{\MyNiceBox}{+O{}+m+m+m}{%
  \begin{tcolorbox}[only=<1->{title={#2}},only=<1-2>{lowerbox=ignored,segmentation hidden},
    colframe=green!50!black,
    colback=green!50!black!10!white,
    #1]
    \onslide<2->{#3}
    \onslide<3->{%
      \tcblower
      #4}
  \end{tcolorbox}%
}


\begin{document}
\begin{frame}
\MyNiceBox{Valency = ?}{Hydrogen, H}{1}
\end{frame}
\end{document}

enter image description here

enter image description here

enter image description here

  • To be edited later on... – user31729 Feb 27 at 12:36
  • i want to define a new tcolorbox with out using onslide in every tcolorbox – sandu Feb 28 at 3:52
  • @sandu: You wrote: A new tcolorbox... with onslide... – user31729 Feb 28 at 19:14

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.