ellipsix informatics
 
 
Trackback URI
2012
Dec
05

Absolute positioning in TikZ and Beamer

Bookmark and Share

I discovered this little trick recently while making a presentation in Beamer. Suppose I have a drawing, done in TikZ, which I want to place such that the origin of the TikZ coordinate system is at a specific absolute position on the page — in my case, 1.5cm below the center.

\begin{tikzpicture}[remember picture,overlay]
  \tikzset{shift={(current page.center)},yshift=-1.5cm}
  % the picture
\end{tikzpicture}

TikZ defines this current page node which can be used for absolute positioning. While I can't directly say "set the origin at (point)" (at least, not as far as I know), I can say "move the origin by (vector)," and fortunately, an anchor point or any point specification in TikZ can be used as a vector. The trick to this little code snippet is that (current page.center) gives the vector from wherever the current origin is to the center of the page. So regardless of where the picture is placed on the page, applying this shift gets you to the page center. Then you can apply any additional shift needed to get wherever you need to on the page.

This trick gets around one of the few shortcomings of Beamer, namely that it has a mind of its own when it comes to laying out content. Don't get me wrong, usually this is a good thing because LaTeX knows better than you do where you should be putting text on the page. But if you're making a graphics-intensive presentation, you'll probably want to put some drawing at a specific absolute position on the page, and LaTeX really isn't built for that.

blog comments powered by Disqus