使用 tikz 将半透明矩形覆盖整个幻灯片是演示中的一种不错的花招。只有一个缺点:如果主题有页脚,则页脚不会被矩形覆盖,这看起来有点丑陋,如您在此处所见:
使用没有页脚的主题显然是一种解决方法,但如果矩形能覆盖整个幻灯片就更好了。有什么想法可以做到这一点吗?
以下是代码:
\documentclass{beamer}
\usepackage{tikz}
\usetheme{Copenhagen}
\newcommand<>{\overlay}[1]{\uncover#2{%
\begin{tikzpicture}[remember picture,overlay]%
\draw[fill=black,opacity=0.70]
(current page.north east) rectangle (current page.south west);
\node at (current page.center) {#1};
\end{tikzpicture}}
}
\begin{document}
\section{Beamer}
\begin{frame}{Beamer}
Some text
\overlay<2>{
\huge \textcolor{white}{
\begin{minipage}{.8\linewidth}
\begin{block}{Really Important}
Some thing one should always KEEP in mind.
\end{block}
\end{minipage}
}
}
\end{frame}
\end{document}
答案1
这可以通过挂接到footline
模板来实现。幸运的是,beamer
提供了\addtobeamertemplate
命令,因此一旦主题加载完毕,就可以直接在那里添加一些额外的代码。对机制进行排序后,下一个问题是如何使其易于使用。我决定做的(尽管可能还有其他方法)是使用\addtobeamertemplate
将叠加层tikzpicture
作为页面上的最后一项。然后我提供了一个可以在这张图片中放置东西的宏。这会在每张幻灯片上清除,因此使用叠加规范可以控制每张幻灯片上显示的内容。这是一个例子(希望从图片中可以清楚地看到叠加层确实覆盖了所有内容。将填充颜色设置为类似的颜色pink
会使其更加清晰):
\documentclass{beamer}
%\url{http://tex.stackexchange.com/q/45420/86}
\usepackage{tikz}
\usetheme{Copenhagen}
\makeatletter
\def\ft@overlay{}
\addtobeamertemplate{footline}{}%
{%
\lineskiplimit0pt
\begin{tikzpicture}[remember picture,overlay]%
\ft@overlay
\end{tikzpicture}%
\gdef\ft@overlay{}%
}
\newcommand<>{\addtooverlay}[1]{%
\only#2{%
\expandafter\gdef\expandafter\ft@overlay\expandafter{\ft@overlay #1}%
}%
}
\makeatother
\begin{document}
\section{Beamer}
\begin{frame}{Beamer}
Some text
\pause
\addtooverlay<.(1)>{%
\draw[fill=black,opacity=0.70]
(current page.north east) rectangle (current page.south west);
\node[text=white,font=\Huge] at (current page.center) {Overlaid};
}
\pause
And yet more text
\end{frame}
\end{document}
答案2
你可以使用类似的技巧@Ulrike Fischer 的回答很好:
\documentclass{beamer}
\usepackage{tikz}
\usetheme{Copenhagen}
\newcommand<>{\overlay}[1]{\only#2{%
\AddToHookNext{shipout/foreground}{%
\begin{tikzpicture}[remember picture,overlay]%
\draw[fill=black,opacity=0.70]
(current page.north east) rectangle (current page.south west);
\node at (current page.center) {#1};
\end{tikzpicture}}}
}
\begin{document}
\section{Beamer}
\begin{frame}{Beamer}
Some text
\overlay<2>{
\huge \textcolor{white}{
\begin{minipage}{.8\linewidth}
\begin{block}{Really Important}
Some thing one should always KEEP in mind.
\end{block}
\end{minipage}
}
}
\only<3>{normal overlay}
\end{frame}
\end{document}