我的 beamer 演示存在问题:我想让 3 个框彼此相邻,它们首先应该同时出现,然后我会指定框出现的时间。如果没有 \onslide,一切都会正常进行,但是当我包含 \overlay 时,事情就变得一团糟:
\documentclass[mathserif]{beamer}
\usetheme{Madrid}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\begin{document}
\begin{frame}
\begin{tcbraster}[raster columns=3,raster column skip=0.05cm, size=small, raster force size=false,size=fbox]
\begin{tcolorbox}[halign=center, valign=center, colframe=blue!80!black, colback=blue!10!lightgray!30, width=3.9cm]
bla
\end{tcolorbox}
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4cm]
bla
\end{tcolorbox}
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4.1cm]
bla
\end{tcolorbox}
\end{tcbraster}
\end{frame}
\begin{frame}
\begin{tcbraster}[raster columns=3,raster column skip=0.05cm, size=small, raster force size=false,size=fbox]
\onslide<1->{
\begin{tcolorbox}[halign=center, valign=center, colframe=blue!80!black, colback=blue!10!lightgray!30, width=3.9cm]
bla
\end{tcolorbox}}
\onslide<1,2->{
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4cm]
bla
\end{tcolorbox}}
\onslide<1,3->{
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4.1cm]
bla
\end{tcolorbox}}
\end{tcbraster}
\end{frame}
\end{document}
如您所见,第二张幻灯片中的对齐方式不符合我的要求,我不希望此处出现换行符。哪里出了问题?
答案1
tcolorbox v4.20
引入了一些beamer support
选项。通过这些选项,您可以对每张幻灯片应用特定选项,或者隐藏特定幻灯片中的框。
以下代码调整 OP 的第二帧tcbitemize
并展示如何使用hide
和alert
选项来依次显示每个新框:
\documentclass[mathserif]{beamer}
\usetheme{Madrid}
\usepackage[most]{tcolorbox}
\begin{document}
\tcbset{beamer alerted/.style={}}
\begin{frame}
\begin{tcbraster}[raster columns=3,raster column skip=0.05cm, size=small, raster force size=false,size=fbox]
\begin{tcolorbox}[halign=center, valign=center, colframe=blue!80!black, colback=blue!10!lightgray!30, width=3.9cm]
bla
\end{tcolorbox}
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4cm]
bla
\end{tcolorbox}
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4.1cm]
bla
\end{tcolorbox}
\end{tcbraster}
\end{frame}
\begin{frame}
\begin{tcbitemize}[raster columns=3, raster column skip=0.05cm, size=small,
raster force size=false,
size=fbox, enhanced,
halign=center, valign=center, colframe=blue!80!black, colback=blue!10!lightgray!30, ]
\tcbitem[width=3.9cm]
bla 1
\tcbitem[width=4cm, hide=<-1>, alert=<2>]
bla 2
\tcbitem[width=4.1cm, hide=<-2>, alert=<3>]
bla 3
\end{tcbitemize}
\end{frame}
\end{document}
注意:在之前的代码中,我不得不使用hide
和alert
选项的强制组合来显示第三个框。我认为hide
应该足够了。如果我找到更好的解决方案,我会更新答案。
答案2
我找到了两种解决方案:如果我改变框的宽度(我之前没有遵守 \textwidth)并将它们缩小,一切都会顺利进行。但我的文本有点太长了,可能更好的方法是受到@samcarter 的评论的启发:只需在 \onslide 的 { 后插入一个 %。两种解决方案:
\documentclass[mathserif]{beamer}
\usetheme{Madrid} %% Themenwahl
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\begin{document}
\begin{frame}
\begin{tcbraster}[raster columns=3,raster column skip=0.05cm, size=small, raster force size=false,size=fbox]
\onslide<1->{
\begin{tcolorbox}[halign=center, valign=center, colframe=blue!80!black, colback=blue!10!lightgray!30, width=3.5cm]
bla
\end{tcolorbox}}
\onslide<1,2->{
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=3.5cm]
bla
\end{tcolorbox}}
\onslide<1,3->{
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4.1cm]
bla
\end{tcolorbox}}
\end{tcbraster}
\end{frame}
\begin{frame}
\begin{tcbraster}[raster columns=3,raster column skip=0.05cm, size=small, raster force size=false,size=fbox]
\onslide<1->{%
\begin{tcolorbox}[halign=center, valign=center, colframe=blue!80!black, colback=blue!10!lightgray!30, width=3.9cm]
bla
\end{tcolorbox}}
\onslide<1,2->{%
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4cm]
bla
\end{tcolorbox}}
\onslide<1,3->{%
\begin{tcolorbox}[halign=center, colframe=blue!80!black,colback=blue!10!lightgray!30, width=4.1cm]
bla
\end{tcolorbox}}
\end{tcbraster}
\end{frame}
\end{document}