我想用 Beamer 重建 PowerPoint 模板。为此,我需要在框架的背景中定位几个图形元素。我尝试了很多方法和代码,但遇到了几个问题。请考虑这个 MWE,例如:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}
{\usebackgroundtemplate{
\begin{picture}(0,0)
\put(0,-50){
\begin{tikzpicture}[overlay]
\node [anchor=south west] (rect) at (0,0) [fill=blue, minimum width=16.0cm,minimum height=0.5cm] {};
\node [anchor=south west] (rect) at (0,0.5) [fill=black, minimum width=16cm, minimum height=2cm] {};
\end{tikzpicture}}
\end{picture}
\begin{picture}(0,0)
\put(0,-225){
\includegraphics[width=3cm]{pictures/image1.png}
\end{picture}
\begin{picture}(0,0)
\begin{tikzpicture}[overlay]
\node[anchor=south west, inner sep=0pt] (image2) at (current page.south west){\includegraphics[width=8cm]{pictures/image2.png}};
\end{tikzpicture}
\end{picture}
}
\begin{frame}
Test
\end{frame}
}
\end{document}
对第二张图片进行评论至少可以给出一个输出。除了这个问题之外,我还在努力解决以下问题:如何强制 beamer 将图形放置在框架的左侧而没有任何边距。使用 \put 的负值可以工作,但不是一个好的解决方案,必须为每个图形元素单独完成。
为什么 image2 甚至没有显示出来?我认为使用页面西南角的节点是一个聪明的主意。
添加东西会使元素改变其位置 - 例如图像 1 上方的某些文本。如何强制元素停留在放置它们的位置?
答案1
尝试这个
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}
\usebackgroundtemplate{
\begin{tikzpicture}[remember picture, overlay] % <----------
\node [anchor=north west] (black rect) at (current page.north west)
[fill=black, minimum width=16cm, minimum height=2cm] {};
\node [anchor=north] at (black rect.south)
[fill=blue, minimum width=16.0cm,minimum height=0.5cm] {};
\node[anchor=south west, inner sep=0pt] (image2) at (current page.south west)
{\includegraphics[width=8cm]{pictures/image2.png}};
\node[anchor=south east, inner sep=0pt] at (current page.south east)
{\includegraphics[width=3cm]{pictures/image1.png}};
\end{tikzpicture}
}
\begin{frame}
Test
\end{frame}
\end{document}