我想使用幻灯片背景来说明 itemize 环境中的各个项目。但是,据我所知,背景图像必须在框架之外指定,并且only
、onslide
、uncover
等似乎无法按预期工作(如果值为 1,则背景显示在所有幻灯片上,否则隐藏在所有幻灯片上)。
这就是我想要使用它的方式,但它当然不起作用:
{
\only<1>{\usebackgroundtemplate{\includegraphics[width=\paperwidth]{assets/background-01.png}}}%
\only<2>{\usebackgroundtemplate{\includegraphics[width=\paperwidth]{assets/background-02.png}}}%
\only<3>{\usebackgroundtemplate{\includegraphics[width=\paperwidth]{assets/background-03.png}}}%
\frame{
\frametitle{Promotion}
\begin{itemize}[<+->]
\item Identifying the target audience
\item Understanding the target audience
\item Identifying partners
\end{itemize}
}
}
谢谢你!
答案1
我认为你想要的是不可能的。看看beamer 是如何构建框架的?并且会看到和background canvas
是background
在任何其他内容之前构建的,并且框架内容是标题和侧边栏之后的最后一部分。因此,即使尝试提供带有覆盖层false
的背景TiKZ
并记住图片,该背景也会覆盖任何先前的层。
下一个代码展示了manual
使用\visible
和构建的解决方案\invisible
。您需要构建与项目一样多的框架,如果您的幻灯片已编号,则需要找到如何调整它们。
\documentclass{beamer}
\usepackage{mwe}
\begin{document}
\usebackgroundtemplate{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-a}}
\begin{frame}{Promotion}
\begin{itemize}
\item\visible<1>{Identifying the target audience}
\item\invisible<1>{Understanding the target audience}
\item \invisible<1>{Identifying partners}
\end{itemize}
Some text
\end{frame}
\usebackgroundtemplate{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-b}}
\begin{frame}{Promotion}
\begin{itemize}
\item\visible<1>{Identifying the target audience}
\item\visible<1>{Understanding the target audience}
\item \invisible<1>{Identifying partners}
\end{itemize}
Some text
\end{frame}
\usebackgroundtemplate{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-c}}
\begin{frame}{Promotion}
\begin{itemize}
\item\visible<1>{Identifying the target audience}
\item\visible<1>{Understanding the target audience}
\item\visible<1>{Identifying partners}
\end{itemize}
Some text
\end{frame}
\end{document}
答案2
现在我也尝试了下面的解决方案。它确实很 hacky,但它更 DRY,这意味着它可以减少代码重复。帧数也没有问题。
非常感谢迪亚博纳斯获取backgroundblock
代码。
\documentclass{beamer}
\usepackage{mwe}
% beamer: How to place images behind text (z-order)
% (https://tex.stackexchange.com/a/134311)
\makeatletter
\newbox\@backgroundblock
\newenvironment{backgroundblock}[2]{%
\global\setbox\@backgroundblock=\vbox\bgroup%
\unvbox\@backgroundblock%
\vbox to0pt\bgroup\vskip#2\hbox to0pt\bgroup\hskip#1\relax%
}{\egroup\egroup\egroup}
\addtobeamertemplate{background}{\box\@backgroundblock}{}
\makeatother
\begin{document}
\begin{frame}{Promotion}
\only<1>{
\begin{backgroundblock}{-1mm}{0mm}
\includegraphics[width=1.01\paperwidth]{example-image-a}
\end{backgroundblock}
}
\only<2>{
\begin{backgroundblock}{-1mm}{0mm}
\includegraphics[width=1.01\paperwidth]{example-image-b}
\end{backgroundblock}
}
\only<3>{
\begin{backgroundblock}{-1mm}{0mm}
\includegraphics[width=1.01\paperwidth]{example-image-c}
\end{backgroundblock}
}
\begin{itemize}[<+->]
\item Identifying the target audience
\item Understanding the target audience
\item Identifying partners
\end{itemize}
Some text
\end{frame}
\end{document}
答案3
这很容易实现\againframe
\documentclass{beamer}
\begin{document}
\setbeamertemplate{background}{\includegraphics[height=\paperheight,width=\paperwidth]{background1}}
\begin{frame}<1>[label=ttt]{testframe}
\begin{itemize}
\item<+-> a
\item<+-> b
\item<+-> c
\item<+-> d
\end{itemize}
\end{frame}
\setbeamertemplate{background}{\includegraphics[height=\paperheight,width=\paperwidth]{background2}}
\againframe<2>{ttt}
\setbeamertemplate{background}{\includegraphics[height=\paperheight,width=\paperwidth]{background3}}
\againframe<3>{ttt}
\setbeamertemplate{background}{\includegraphics[height=\paperheight,width=\paperwidth]{background4}}
\againframe<4>{ttt}
\end{document}
答案4
我想添加@Denis Drescher 答案的更正版本
\documentclass{beamer}
\usepackage{mwe}
% beamer: How to place images behind text (z-order)
% (https://tex.stackexchange.com/a/134311)
\makeatletter
\newbox\@backgroundblock
\newenvironment{backgroundblock}{
\global\setbox\@backgroundblock=\vbox\bgroup%
\unvbox\@backgroundblock%
\vbox to0pt\bgroup\hbox to0pt\bgroup%
\ignorespaces
}{\egroup\egroup\egroup}
\addtobeamertemplate{background}{\box\@backgroundblock}{}
\makeatother
\begin{document}
\begin{frame}{Promotion}
\only<1>{
\begin{backgroundblock}
\includegraphics[width=\paperwidth]{example-image-a}
\end{backgroundblock}
}
\only<2>{
\begin{backgroundblock}
\includegraphics[width=\paperwidth]{example-image-b}
\end{backgroundblock}
}
\only<3>{
\begin{backgroundblock}
\includegraphics[width=\paperwidth]{example-image-c}
\end{backgroundblock}
}
\begin{itemize}[<+->]
\item Identifying the target audience
\item Understanding the target audience
\item Identifying partners
\end{itemize}
Some text
\end{frame}
\end{document}
问题是背景图像之前的空格没有被忽略。我不相信此代码在所有情况下都有效。无论如何,您都可以%
在括号后添加符号,以防止乳胶将换行符视为空格。