I am trying to overlay some transparent boxes over a picture using TikZ within a Beamer frame. The code I use is the following:

\documentclass{beamer}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}

\begin{document}
\begin{frame}
\begin{tikzpicture}[remember picture, overlay]
\onslide<1->{
\draw []
(-0.95,-2.75) rectangle (1.5,-4.00)
node (rNode) {};

\tikzset
{pt/.style={circle,fill=red,inner sep=0mm,minimum size=4pt}}
\node[pt] at (rNode.center){};
\node[pt] at (rNode.west){};
\node[pt] at (rNode.south){};
\node[pt] at (rNode.east){};
\node[pt] at (rNode.north){};
};
\end{tikzpicture}
\end{frame}
\end{document}


The problem is that the anchors of the TikZ rectangles that I create are incorrect: they seem to be the anchors of a different rectangle that I did not create). I would like to know what I am doing wrong and how to solve this problem.

-
@zeroth Really? Can you give an example of that? Ricardo, it's going to be hard to figure out what's going on without a minimal working example (MWE). Could you narrow down the problem and post one? – Loop Space Feb 6 '13 at 17:08
@AndrewStacey I will quickly remove my comment. (I have used it in all my frames, for apparently no reason!). Thanks! – zeroth Feb 6 '13 at 17:30
@AndrewStacey,@zeroth : i've just updated my question and included both a working example and the PDF generated with PDFLatex. The only thing that is left for the working example is the image over which the overlay is attempted: if you want me to upload it, just tell me! – Ricardo Feb 6 '13 at 17:55
I've just updated the question and I included now a very simple example: a beamer frame with a tikz rectangle which has 4 of its default anchors (north, south, west and east) highlighted with a red circle. You can see that instead of being placed where they are supposed to be placed, all of them appear close to the "south east" anchor. Anybody can help? – Ricardo Feb 6 '13 at 18:28
Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say "thank you" to users who helped you. – Claudio Fiandrino Mar 18 '13 at 11:17

### Disclaimer

The other answers already explain the problem, but I start write the same motivation before dinner, so I left it anyway.

Actually, the behaviour you're facing is correct because when you use

\draw []
(-0.95,-2.75) rectangle (1.5,-4.00)
node (rNode) {};


you're placing the node just in the lower right corner, but the node does not have the dimension of the rectangle. You have already prove this with your example, but just to emphasize it a bit, here is another proof. The following example will place a cross out node exactly on rNode:

\documentclass[tikz,png,border=2pt]{standalone}
\usetikzlibrary{backgrounds,shapes.misc,positioning}

\begin{document}
\begin{tikzpicture}
\draw []
(-0.95,-2.75) rectangle (1.5,-4.00)
node (rNode) {};
\node[draw,cross out,blue,scale=1.1] at (rNode){};

\begin{scope}[on background layer]
\tikzset
{pt/.style={circle,fill=red,inner sep=0mm,minimum size=4pt}}
\node[pt] at (rNode.center){};
\node[pt] at (rNode.west){};
\node[pt] at (rNode.south){};
\node[pt] at (rNode.east){};
\node[pt] at (rNode.north){};
\end{scope}
\end{tikzpicture}
\end{document}


The result:

Thus the correct way is to use the standard shape rectangle inside a \node:

\documentclass{beamer}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}

\begin{document}
\begin{frame}
\begin{tikzpicture}[remember picture, overlay]
\onslide<1->{
\node[rectangle, draw, minimum height=1.25cm, minimum width=2.45cm]
(rNode) at (0.275,-3.375){};

\tikzset
{pt/.style={circle,fill=red,inner sep=0mm,minimum size=4pt}}
\node[pt] at (rNode.center){};
\node[pt] at (rNode.west){};
\node[pt] at (rNode.south){};
\node[pt] at (rNode.east){};
\node[pt] at (rNode.north){};
};
\end{tikzpicture}
\end{frame}
\end{document}


The result:

To come back to the original question, the best thing to do is to include inside a \node your images with the inner sep option set to 0pt (to have exactly the anchors on the border); for example:

\documentclass{beamer}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mwe} % for dummy images
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}
\tikzset{pt/.style={
circle,
fill=blue,
inner sep=0mm,
minimum size=1pt,
}
}
\tikzset{legend/.style={
rectangle,
rounded corners,
draw,
top color=white,
bottom color=#1,
align=center,
font=\footnotesize,
}
}

\begin{document}
\begin{frame}
\begin{tikzpicture}[remember picture, overlay]
\onslide<1->{
\node[inner sep=0pt](rNode) at (2,0){\includegraphics[scale=0.3]{example-image}};

\node[pt] at (rNode.center){};
\node[pt] at (rNode.west){};
\node[pt] at (rNode.south){};
\node[pt] at (rNode.east){};
\node[pt] at (rNode.north){};

\node[legend={red},anchor=south west,yshift=1ex] at (rNode.north) {Some description};
\node[legend={red},anchor=north east,yshift=-1ex,text width=1.75cm] at (rNode.south) {Some other description};
};
\onslide<2->{
\node[inner sep=0pt](xNode) at (8,2){\includegraphics[scale=0.3]{example-image-a}};

\node[pt] at (xNode.center){};
\node[pt] at (xNode.west){};
\node[pt] at (xNode.south){};
\node[pt] at (xNode.east){};
\node[pt] at (xNode.north){};

\node[legend={cyan!60!blue!60},anchor=west,xshift=1em,text width=1cm] at (xNode.east) {Some other text};
};
\onslide<3->{
\node[inner sep=0pt](yNode) at (8,-2){\includegraphics[scale=0.3]{example-image-b}};

\node[pt] at (yNode.center){};
\node[pt] at (yNode.west){};
\node[pt] at (yNode.south){};
\node[pt] at (yNode.east){};
\node[pt] at (yNode.north){};

\node[legend={green!60!lime!60},anchor=west,xshift=1em,text width=1cm] at (yNode.east) {Some other text};
\node[legend={green!60!lime!60},anchor=north,yshift=-1ex] at (yNode.south) {Yet another description};

};

\draw<4->[-stealth,red](rNode.east)--(xNode.west);
\draw<5->[-stealth,red](xNode.south)--(yNode.north);
\path<6->[-stealth,red](yNode.west)edge[bend left](rNode.south);

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


The result:

Notice how in such a way you can access the standard anchors of the nodes you created to place arrows or descriptive text.

For completeness, if instead you have to make operations inside a single picture the best procedure is to refer to In a beamer slide highlight a region of an image with a rectangle overlay. That approach uses coordinates, but you can always use the anchors (perhaps with the help of the calc library).

An example:

\documentclass{beamer}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mwe} % for dummy images
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{pt/.style={
circle,
draw=blue,
fill=green!50!lime,
inner sep=0mm,
minimum size=3pt,
}
}
\tikzset{legend/.style={
rectangle,
rounded corners,
draw,
top color=white,
bottom color=#1,
align=center,
font=\footnotesize,
}
}

\begin{document}
\begin{frame}
\begin{tikzpicture}[remember picture, overlay]
\onslide<1->{
\node[inner sep=0pt](rNode) at (5.5,0){\includegraphics[scale=0.75]{example-image}};

\foreach \anchor in
{north,south,east,west,center,north west,north east,
south west, south east,center}{
\node[pt] at (rNode.\anchor){};
}

};
\node<2->[legend={red},anchor=south west,yshift=1ex] (x) at ($(rNode.north)!0.5!(rNode.center)$) {Some description};
\node<3->[legend={red},anchor=north east,yshift=-1ex,text width=1.75cm]
(y) at ($(rNode.south)!0.65!(rNode.center)$) {Some other description};

\path<4->[-stealth,red, thick](y.west) edge[bend left, looseness=2](x.west);

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


The result:

-
Thank you very much for your help Claudio! – Ricardo Feb 7 '13 at 13:38
If the answer helped you, please consider to accept it. I would courteously suggest you for the future to upvote all answers you find useful, including those to others' questions and to check/accept the best answers to your own questions by clicking the green tick on the left-hand side of the answer. This will help the community. – Claudio Fiandrino Feb 7 '13 at 13:50

Your problem is the definition of your node, i.e. you do not define a rectangle node.

This code:

\draw []
(-0.95,-2.75) rectangle (1.5,-4.00)
node (rNode) {};


means:

1. Draw a rectangle between (-0.95,-2.75) and (1.5,-4.00)
2. Then draw an empty ({}) text node at (1.5,-4.00), named rNode

Your empty text node has a rectangular shape by default, with width and height equal to 2 x inner sep. So, when you write (rNode.south), Tikz draw at the right place :-)

You may better write your first rectangle like this:

\node[draw,minimum width=2.45cm,minimum height=1.25cm] (rNode) at (.275,-3.375) {};

-