# How to fix a coordinate for a node wrt grid in Tikz picture (Tikz101)

I am at Tikz 101 level so am figuring out a unified way of drawing graphics so that the all are positioned wrt to a fixed ref point in all slides in a beamer document.

To get a reference coordinate, I thought of first putting a grid on slide in beamer document. Can any one tell me how can I specify the coordinate for node b1. I am assuming that once I fix the location of first node, the rest of the blocks will not require any node reference as their position will be defined in reference to node b1. My MWE is:

\documentclass{beamer}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{text comp}
\usetikzlibrary{shapes.geometric ,arrows}

\begin{document}
% Definition of blocks:
\tikzstyle{block} = [rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, fill=white]

\begin{frame}
\begin{center}
\begin{tikzpicture}[node distance=2 cm]
\draw [step=0.5cm,gray,very thin](-5,-2) grid (5,5);
\draw (+0,+1.5) [red] circle (0.5 cm);

\node(b1) [block] {B1};
\node(b2) [block, right of=b1, xshift=0.3cm] {B2};

\end{tikzpicture}
\end{center}
\end{frame}
\end{document}


Is there a better way to achieve this ?

• another TikZ 101 point: tex.stackexchange.com/questions/52372/… Mar 3, 2016 at 18:11
• You can position nodes using \node at (x,y) {}; but whether this is the best way depends on where you want to position the node b1. Where do you want it in respect to the page? Mar 3, 2016 at 18:28
• I want it to be in positioned in such a way that my figure starts from top left corner of my tikzpicture. Mar 3, 2016 at 18:31
• Then maybe \node[anchor=north west] at (x,y); would be the command you need, so the top left corner of the node will be at the coordinate (x,y). Mar 3, 2016 at 23:15
• With [remember picture] you have access to the anchor points like (current page.center) and (current page.south east). Just interpolate to find any point on the page. Mar 4, 2016 at 3:04

With remember picture,overlay it is possible to position FIG tikz anywhere on the page.

this requires two compalitions.

\documentclass{beamer}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{text comp}
\usetikzlibrary{shapes.geometric ,arrows}

\begin{document}

\begin{frame}
\begin{center}
\begin{tikzpicture}[node distance=2 cm,remember picture,overlay,shift={(current page.center)}]

\node[circle,draw](b1)at (0,0) {B1} ;
\draw[gray] (current page.north) -- (current page.south);
\draw[gray] (current page.east) -- (current page.west);
\draw [step=0.5cm,gray,very thin](-.4\textwidth,0.4\textheight) grid (.4\textwidth,-0.4\textheight);

\end{tikzpicture}
\end{center}
\end{frame}
\end{document}