11

Is it possible to make the coordinate system to be fixed on several slides in a beamer presentation? So that each point with the same coordinates in different tikzpicture environments on different slides is in exactly the same position in the resulting PDF?

Example:

\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}

How to modify this example, such that on both slides the circle at position (0,0) overlays?

Thomas W.
  • 703

2 Answers2

16

you can set the overlay and remember picture option to the 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}

enter image description here

With these options you have also access to the current page anchor, which allows for cool stuff like:

\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}

enter image description here

d-cmst
  • 23,095
1

You can also fix the position using the textpos package and textblock* environment. This allows you to fix anything to a fixed coordinate position of the slide.

Do not that this works as an overlay and will therefore not interact typesetting-wise with stuff outside in inserted textblock.

A small working example:

\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}
Rasmus
  • 1,270
  • 1
  • 10
  • 25