1

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 ?

NAASI
  • 2,809

1 Answers1

3

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}

enter image description here

rpapa
  • 12,350