# Computed coordinates are all the same?

It's embarrassing question time. Why are my computed coordinates all showing up at the same location? The larger filled quarter circles are drawn with:

current page.\x


where \x is south west, north west, north east, south east, and these work just fine. But when I compute my own locations as:

\coordinate (South West) ($(current page.south west) + ( \XMargin, \XMargin)$) ;
\coordinate (North West) ($(current page.north west) + ( \XMargin,-\XMargin)$) ;
\coordinate (North East) ($(current page.north east) + (-\XMargin,-\XMargin)$) ;
\coordinate (South East) ($(current page.south east) + (-\XMargin, \XMargin)$) ;


they all show at the same location, as shown by the concentric circles:

The correct output should have those concentric circles distributed around the page.

## Code:

\def\PaperWidth{3.0 in}
\def\PaperHeight{2.0 in}
\def\Bleed{0.15 in}
\def\SafetyMargin{0.35 in}

\documentclass{article}
\usepackage[
paperwidth=\PaperWidth,
paperheight=\PaperHeight,
margin=\dimexpr\Bleed+\SafetyMargin\relax,
]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{empty}

\usepackage{printlen}\uselengthunit{in}
\newlength{\XMargin}

\begin{document}
\pgfmathsetlength{\XMargin}{\Bleed + \SafetyMargin}
\noindent
\begin{tikzpicture}[overlay, remember picture]

\coordinate (South West) ($(current page.south west) + ( \XMargin, \XMargin)$) ;
\coordinate (North West) ($(current page.north west) + ( \XMargin,-\XMargin)$) ;
\coordinate (North East) ($(current page.north east) + (-\XMargin,-\XMargin)$) ;
\coordinate (South East) ($(current page.south east) + (-\XMargin, \XMargin)$) ;

% Why are these all showing up at the same point???
\foreach [count=\xi] \x/\Color/\InnerSep  in {South West/orange/4, North West/brown/5, North East/red/6, South East/blue/7} {
\node [circle, draw=\Color, inner sep=\InnerSep pt] at (\x) {\xi};
}

% This works just fine
\foreach \x/\Color in {south west/orange, north west/brown, north east/red, south east/blue} {
\node [circle, fill=\Color, inner sep=0.25in] at (current page.\x) {};
}

\node at (current page.center) {xmargin is \printlength{\XMargin}};

\end{tikzpicture}
\end{document}

-
OMG, just figured it out!!! Can't believe that that took me soooo long. I'll wait some time before posting an, in case others like a challenge... :-) – Peter Grill Oct 28 '12 at 0:09
at (Damn character minimum.) – Qrrbrbirlbel Oct 28 '12 at 0:11
@Qrrbrbirlbel: Damm you are quick. Yep that is where it is at. You should post an answer. Don't know why that did not trigger a syntax error though. – Peter Grill Oct 28 '12 at 0:13
@percusse: Well unfortunately I am in the US and they use the British System. Even the British don't use the British System!!! – Peter Grill Oct 28 '12 at 0:14
I also wonder why the missing at with a coordinate involved doesn't trigger a message error. – Gonzalo Medina Oct 28 '12 at 1:04

Well, as you already figured out, you missed an at in your coordinate specification:

\coordinate (South West) at ($(current page.south east) + (-\XMargin, \XMargin)$);
\coordinate (North West) at ($(current page.south west) + ( \XMargin, \XMargin)$);
\coordinate (North East) at ($(current page.north west) + ( \XMargin,-\XMargin)$);
\coordinate (South East) at ($(current page.north east) + (-\XMargin,-\XMargin)$);


-

I also wonder why the missing at with a coordinate involved doesn't trigger a message error.

The reason is that \coordinate (South West) ($(current page.south west) + ( \XMargin, \XMargin)$) ; is a completely valid TikZ command. It says "Mark (0,0) as a coordinate with label South West and then move to (complicated point).". The (0,0) is because there isn't an explicit coordinate specification and the coordinate dimensions are all set to 0 at the start of a path. The interpretation is because (in the absence of beamer), \coordinate expands to \path coordinate and so the command is:

\path coordinate (South West) ($(current page.south west) + ( \XMargin, \XMargin)$) ;


which is completely valid. Of course, it doesn't do anything (apart from mess with the bounding box) but it does mean that you could do:

\coordinate (a) (0,1) [draw] -- (2,0) coordinate (b);


and it would draw a line from (0,1) to (2,0) and stick another coordinate there. What you can't do is:

\coordinate[draw] (a) -- (2,0);


for two reasons: the path doesn't get it's official initial move (the coordinate is at (0,0) but the path hasn't actually moved there), and the draw command is given to the coordinate node where it does nothing (since coordinate nodes have no shape).

Now, of course, if you were planning on anything more complicated than \coordinate (a) at (38,42); then you'd probably use a \path (or \draw or \fill) to begin with. So this is probably unnecessary if it were there to make \coordinate more flexible. But it isn't, it's there to ensure that \coordinate behaves exactly like \path coordinate so that you have peace of mind in knowing that however you specify coordinates, they all turn out just the same.

Some code to play with:

\documentclass{article}
%\url{http://tex.stackexchange.com/q/79358/86}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\coordinate (a) (0,1) [draw] -- (2,0) coordinate (b);
\draw (a) to[bend left] (2,0);
\end{tikzpicture}
\end{document}


-