[Tex/LaTex] How to vertically align (center) tikz image within the whole page

formattingtikz-pgfvertical alignment

I am generating a large number of graphics using tikz which I will need to reuse through various places in my document, as well as in animations. Thus, I am pre-creating all these plots. To assure that all page sizes are the same in the plots, I am using the geometry package. Horizontal centering is easy, but even after a lot of looking I could not figure out how to vertically center a tikz graphic on the entire page. Here is an example:

\documentclass{article}
\usepackage{tikz}
\usepackage[ paperwidth=4cm,paperheight=4cm]{geometry}

\begin{document}

\begin{center}
\begin{tikzpicture}
    \draw node[fill,circle,minimum size=2cm] {};
\end{tikzpicture}
\end{center}

\end{document}

Which makes this:

enter image description here

How to get the node in the exact center of the page?

Best Answer

Using the current page Node (see ยง17.13.2 of tikz doc) :

\documentclass{article}
\usepackage{tikz}
\usepackage[ paperwidth=4cm,paperheight=4cm]{geometry}

\begin{document}

\begin{tikzpicture}[remember picture, overlay]
    \draw node[fill,circle,minimum size=2cm] at (current page.center) {};
\end{tikzpicture}

\end{document}

enter image description here

With 2 nodes in the same tikzpicture :

\documentclass{article}
\usepackage{tikz}
\usepackage[ paperwidth=4cm,paperheight=4cm]{geometry}

\begin{document}

\begin{tikzpicture}[remember picture, overlay]
  \draw node[fill,circle,minimum size=2cm] at (current page.center) {};
  \draw node[fill=blue, rectangle, minimum size=2cm] at
  (current page.north) {};
\end{tikzpicture}

\end{document}

enter image description here

And With 2 tikzpicture :

\documentclass{article}
\usepackage{tikz}
\usepackage[ paperwidth=4cm,paperheight=4cm]{geometry}
\begin{document}

\begin{tikzpicture}[remember picture, overlay]
  \draw node[fill,circle,minimum size=2cm] at (current page.center) {};
  \draw node[fill=blue, rectangle, minimum size=2cm] at
  (current page.north) {};
\end{tikzpicture}


\begin{tikzpicture}[remember picture, overlay]
  \draw node[fill=red, circle,minimum size=5mm, anchor=south west,
  xshift=5mm, yshift=5mm] at
  (current page.south west) {};
\end{tikzpicture}

\end{document}

enter image description here