在LaTeX Beamer中拥有多个幻灯片模板

7
我想使用LaTeX beamer创建演示文稿,其中有两种不同的幻灯片模板/布局:一种是带有背景图像的幻灯片,另一种是没有指定背景图像的幻灯片模板/布局。
是否有什么技巧可以在beamer中实现这一点?

你试过在这里问吗:http://tex.stackexchange.com/? - pgb
4个回答

1
这可以通过新的框架选项轻松完成:
\documentclass{beamer}

\defbeamertemplate{background canvas}{mydefault}{%
  \includegraphics[width=1cm]{example-image-duck}
}
\defbeamertemplate{background canvas}{fullimage}{%
  \includegraphics[width=\paperwidth]{example-image-duck}
}

\BeforeBeginEnvironment{frame}{%
  \setbeamertemplate{background canvas}[mydefault]%
}

\makeatletter
\define@key{beamerframe}{fullimage}[true]{%
  \setbeamertemplate{background canvas}[fullimage]%
}
\makeatother

\begin{document}

\begin{frame}
  left
\end{frame} 

\begin{frame}[fullimage]
  right
\end{frame}

\begin{frame}
  is left again
\end{frame}

\end{document}

1

基本上,这归结于在每个\begin{frame}...\end{frame}之前放置\usebackgroundtemplate


1
如果您想为单个幻灯片设置特定的背景图片,只需放置一个

{\usebackgroundtemplate{\includegraphics[width=\paperwidth]{background.jpg}}

"

在你的\begin{frame}之前直接放置。

"

0

如果我理解正确,问题是如何同时生成两份演示文稿。为此,您可以使用一些低级别的TeX命令和几个文件。

Presentation.tex 中可能会有

%&pdftex
\relax
\immediate\write18{pdflatex -synctex=1 PresentationWithBG.tex}
\relax
\immediate\write18{pdflatex -synctex=1 PresentationWithoutBG.tex}
\end

这是唯一一个需要在上面运行latex的文件,您可以使用pdftex --shell-escape Presentation.tex来运行。 但您还需要以下内容。

PresentationWithBG.tex中(请注意,在每个帧之前实际上不需要使用\usebackgroundtemplate):

\documentclass{beamer}
\setbeamercolor{background canvas}{bg=}
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{<your_background_fig>}}
\input{PresentationContent}

PresentationWithoutBG.tex 文件中:
\documentclass{beamer}
\input{PresentationContent}

PresentationContent.tex 中:
\begin{document}
[All your actual presentation goes here...]
\end{document}

当你运行pdftex --shell-escape Presentation.tex时,你会得到PresentationWithBG.pdfPresentationWithoutBG.pdf

请注意,在Presentation.tex中的%&pdftex确保无论哪个版本的TeX正在运行,都会切换到正确的模式。实际上,你可以使用pdflatex来运行它。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接