我怎样才能将 pgf 图像的内容放在标题栏后面?我尝试使用如何在投影仪框架中插入背景图像?但如果框架有动画,此方法就会失败,而且pgfonlayer
似乎没有帮助。
平均能量损失
\documentclass[]{beamer}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
\usetikzlibrary{backgrounds}
% Frame title
\defbeamertemplate*{frametitle}{ubuntu}[1][]
{%
\begin{tcolorbox}[enhanced,sharp corners,spread upwards,frame hidden,boxrule=0pt,interior style tile={width=\paperwidth}{example-image-a},before skip=0pt,halign=center]
\usebeamercolor{frametitle}\color{fg}
\insertframetitle
\end{tcolorbox}
}
\begin{document}
%% FRAME_START
\begin{frame}{Foo}
\begin{tikzpicture}[overlay,remember picture]
\begin{pgfonlayer}{background} % <--- this does not help, even if I wrap the tcolorbox inside a tikzpicture
\draw[fill=red] ([shift={(5mm,-5mm)}]current page.north west) rectangle (current page.south east);
\node<+-> at (current page.center) {I'd like this picture to be behind the header.};
\node<+-> at ([yshift=-1cm]current page.center) {And I want to be able to put pauses in my picture like this.};
\end{pgfonlayer}
\end{tikzpicture}
\end{frame}
\end{document}
答案1
背景层tikzpicture
仍是图片的一部分。它不会神奇地沉入图片之外的东西后面——就像绘画的背景不会沉入画布后面一样。
要将内容放在幻灯片的背景中,您需要 Beamer 方法 --- 而不是 Ti钾Z. 有关各种可用层的详细信息,请参阅 Beamer 手册。除 之外background canvas
,background
可能也会引起人们的兴趣。
您想要设置(可能在定义之后)相关的 Beamer 模板 - 就像您对标题元素所做的那样。
下面是一个示例,说明如何定义和设置background canvas
有或无 Ti钾Z. 对于简单的阴影或色块,请使用 Beamer 方法。对于更复杂的效果,请使用tikzpicture
或类似方法。
\documentclass[]{beamer}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
% Frame title
\defbeamertemplate*{frametitle}{ubuntu}[1][]
{%
\begin{tcolorbox}[enhanced,sharp corners,spread upwards,frame hidden,boxrule=0pt,interior style tile={width=\paperwidth}{example-image-a},before skip=0pt,halign=center]
\usebeamercolor{frametitle}\color{fg}
\insertframetitle
\end{tcolorbox}%
}
\defbeamertemplate{background canvas}{red box}{\color{red}\vrule width\paperwidth height\paperheight}
\begin{document}
\setbeamertemplate{background canvas}[red box]
%% FRAME_START
\begin{frame}{Foo}
\begin{tikzpicture}[overlay,remember picture]
\node<+-> at (current page.center) {I'd like this picture to be behind the header.};
\node<+-> at ([yshift=-1cm]current page.center) {And I want to be able to put pauses in my picture like this.};
\end{tikzpicture}
\end{frame}
\setbeamertemplate{background canvas}{% use a minipage if you don't want the image to occupy the whole area - you probably want to set background rather than background canvas in this case
% \begin{minipage}[t]{\paperwidth}
\includegraphics[height=\paperheight,width=\paperwidth]{example-image-a}%
% \end{minipage}%
}
\begin{frame}{Image}
With an image.
\end{frame}
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}[x=\paperwidth,y=\paperheight]
\fill [left color=blue,right color=green] (0,0) rectangle (1,1);
\foreach \i [evaluate=\i as \j using int(\i+2)] in {0,2,4,6,8} \fill [white,opacity=\i/10] (0,\i/10) rectangle (\paperwidth,\j/10);
\end{tikzpicture}%
}
\begin{frame}{Pic}
With a picture.
\end{frame}
\setbeamertemplate{background canvas}[default]
\begin{frame}{Default}
Sans.
\end{frame}
\end{document}
由于 Okular 错误,目前没有可用的图像。很抱歉剥夺了读者的观看机会example-image-a
。
不存在暂停等问题 - 这些都不会影响内容frame
。