1. 2012
    Dec
    05

    Absolute positioning in TikZ and Beamer

    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 …