是否可以将坐标系固定在投影仪演示文稿的几张幻灯片上?这样,tikzpicture
不同幻灯片上不同环境中具有相同坐标的每个点在生成的 PDF 中都处于完全相同的位置?
例子:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\draw (0,0) circle (1cm);
\end{tikzpicture}
\end{frame}
\begin{frame}
\begin{tikzpicture}
\draw (0,0) circle (1cm);
\draw (2,2) circle (2cm);
\end{tikzpicture}
\end{frame}
\end{document}
如何修改此示例,使得两张幻灯片上的 (0,0) 位置处的圆圈重叠?
答案1
您可以将overlay
和remember picture
选项设置为tikzpicture
:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{tikzpicture}[overlay,remember picture]
\draw (0,0) circle (1cm);
\end{tikzpicture}
\end{frame}
\begin{frame}
\begin{tikzpicture}[overlay,remember picture]
\draw (0,0) circle (1cm);
\draw (2,2) circle (2cm);
\end{tikzpicture}
\end{frame}
\end{document}
通过这些选项,你还可以访问锚点current page
,它可以实现一些很酷的东西,例如:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{tikzpicture}[overlay,remember picture,every node/.style={draw,minimum size=2.5cm,circle}]
\node [anchor=east] at (current page.east){};
\node [anchor=west] at (current page.west){};
\node [anchor=north] at (current page.north){};
\node [anchor=south] at (current page.south){};
\end{tikzpicture}
\end{frame}
\begin{frame}
\begin{tikzpicture}[overlay,remember picture,every node/.style={draw,minimum size=2.5cm,circle}]
\node [anchor=east] at (current page.east){};
\node [anchor=west] at (current page.west){};
\node [anchor=north] at (current page.north){};
\node [anchor=south] at (current page.south){};
\node at (current page.center){};
\end{tikzpicture}
\end{frame}
答案2
textpos
您还可以使用包和环境来固定位置textblock*
。这允许您将任何内容固定到幻灯片的固定坐标位置。
不要将其作为覆盖层,因此不会与插入的文本块外面的内容进行排版交互。
一个小的工作示例:
\documentclass{beamer}
\usepackage[absolute,overlay]{textpos}
\usepackage{tikz}
\begin{document}
\begin{frame}{Frame Title}
\begin{textblock*}{.0\textwidth}(13mm,77mm)
\begin{tikzpicture}
\node (x) {Here's a node};
\end{tikzpicture}
\end{textblock*}
\end{frame}
\end{document}