我目前正在准备博士论文答辩的 beamer 演示文稿。
我以网址中的示例为例blackboard主题获得黑板风格的演示。
该模板包含一个简短的脚本,该脚本使用随机生成器在黑色背景上随机散布灰尘痕迹以模仿粉笔痕迹(参见下面的 MWE)。
问题是,与此同时,我还使用覆盖层逐个显示幻灯片布局。每次使用布局命令时都会执行该脚本,这会大大减慢编译速度。我不太熟悉 latex 中的控制语句,所以我的问题如下:
我如何修改此脚本以便仅在幻灯片结束后刷新背景,而不是在每次布局命令之后刷新?
评论:
1) 我使用的是 Augie 字体,但我没有将其包含在 MWE 中,以便更容易编译
2)以防万一,我应该使用包\begin{textblock*} \end{textblock*}
中的环境textpos
来定位幻灯片上的文本。
这是我的 MWE:
\documentclass[10pt,mathserif]{beamer}
\usepackage[francais,english]{babel}
\usepackage[utf8] {inputenc} %for ISOlatin1 (8859-1) sources
\usepackage[T1] {fontenc} %for polices DC 8bits
%%%Fancy fonts
%\usepackage{emerald}
%\usepackage{eulervm}
%%%
%%Extra packages
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usepackage[absolute,overlay]{textpos}
%set text colors for different objects
\setbeamercolor{frametitle}{fg=white}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{alerted text}{fg=white}
\setbeamercolor{example text}{fg=white}
%%Black background
\setbeamercolor{background canvas}{bg=black}
%%%%%%%%%%%%%%%%%%%%%%
%%%%%Script: Random Dust Trails%%%%%%%%%%%%%%%
\pgfmathsetseed{\number\pdfrandomseed} % seed for random generator
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth, \the\paperheight);
\foreach \i in {1,...,30} {
\pgfmathsetmacro{\x}{random(0,10000)/5000-1}%
\pgfmathsetmacro{\y}{random(0,10000)/10000-0.1}%
\pgfmathsetmacro{\r}{random(0,10000)/1000-5}%
\rotatebox{\r}{
\pgftext[at=\pgfpoint{\x\paperwidth}{\y\paperheight}, left, base]{\includegraphics[width=\textwidth]{paintstroke.png}}
}
};
\end{tikzpicture}
}
%%%%%%%%%%%%%%%%%%%%%%
%%No navigation bar
\setbeamertemplate{navigation symbols}{}
\begin{document}
\begin{frame}
\begin{itemize}
\item<1-> bla slide 1
\item<2-> blu slide 1
\item<3-> blub slide 1
\end{itemize}
\end{frame}
%%I want the background to be refreshed with the Dust Trails script only at the end of the frame
\begin{frame}
\begin{itemize}
\item<1-> bla slide 2
\item<2-> blu slide 2
\item<3-> blub slide 2
\end{itemize}
\end{frame}
\end{document}
这是我的第一篇帖子,所以如果我在消息格式上做了一些违法的事情,请谅解 ;-)。
提前致谢,
雅尼克
答案1
为了防止每次叠加时都随机生成,这里有一个解决方案,将图片存储在 a 中savebox
并重复使用。使用命令\background
可以刷新灰尘痕迹。
\documentclass[10pt,mathserif]{beamer}
\usepackage[francais,english]{babel}
\usepackage[utf8] {inputenc} %for ISOlatin1 (8859-1) sources
\usepackage[T1] {fontenc} %for polices DC 8bits
%%%Fancy fonts
%\usepackage{emerald}
%\usepackage{eulervm}
%%%
%%Extra packages
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usepackage[absolute,overlay]{textpos}
\usepackage{etoolbox}
%set text colors for different objects
\setbeamercolor{frametitle}{fg=white}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{alerted text}{fg=white}
\setbeamercolor{example text}{fg=white}
%%Black background
\setbeamercolor{background canvas}{bg=black}
%%%%%%%%%%%%%%%%%%%%%%
%%%%%Script: Random Dust Trails%%%%%%%%%%%%%%%
\pgfmathsetseed{\number\pdfrandomseed} % seed for random generator
\setbeamertemplate{background}{
\usebox{\mypicture}
}
%%%%%%%%%%%%%%%%%%%%%%
\BeforeBeginEnvironment{frame}{%
\begin{lrbox}{\mypicture}
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth, \the\paperheight);
\foreach \i in {1,...,30} {
\pgfmathsetmacro{\x}{random(0,10000)/5000-1}%
\pgfmathsetmacro{\y}{random(0,10000)/10000-0.1}%
\pgfmathsetmacro{\r}{random(0,10000)/1000-5}%
\rotatebox{\r}{
\pgftext[at=\pgfpoint{\x\paperwidth}{\y\paperheight}, left, base]{\includegraphics[width=\textwidth]{paintstroke.png}}
}
};
\end{tikzpicture}
\end{lrbox}
}
%%No navigation bar
\setbeamertemplate{navigation symbols}{}
\begin{document}
\newsavebox{\mypicture}
\begin{frame}
\begin{itemize}
\item<1-> bla slide 1
\item<2-> blu slide 1
\item<3-> blub slide 1
\end{itemize}
\end{frame}
\begin{frame}
\begin{itemize}
\item<1-> bla slide 2
\item<2-> blu slide 2
\item<3-> blub slide 2
\end{itemize}
\end{frame}
\end{document}