It seems that the two lines in the following code are not equivalent:

%  \tikz \coordinate at \coord;
 \tikz \node[coordinate] at \coord {};

Namely, the first (commented) line gives an error when used in place of the second. My understanding of the \coordinate command is that it is equivalent to \node[coordinate] {}, so am I missing something or is this a bug?

This question seems to have a similar flavor as Use macro as coordinate in pgfplots plot (among others) but this is not an issue of expandability: \coord is obviously fully expandable and indeed, works in what appears to be the same context in a nearly identical command.


In a normal picture \node is equivalent to \path node and \coordinate is equivalent to \path coordinate:

macro:->\tikz@path@overlay {node}

macro:->\tikz@path@overlay {coordinate}

macro:#1->\let \tikz@signal@path =\tikz@signal@path \pgfutil@ifnextchar <{\tikz@path@overlayed {#1}}{\path #1}

(It is a little different for overlays, e.g. use in beamer)

The difference between both is that \node is more flexible in the syntax i.e. can have different things follow. It can have a name or not, for example and the order is not fixed. Because of this the following material is always expanded before it is parsed. This takes care of the \coord macro. However, \coordinate has quite a fixed syntax of \coordinate[<options>] (<name>) at (<position>);, and therefore are parsed differently.

Your example code doesn't have the (<name>) part which causes the first error. An unnamed coordinate doesn't make sense. However, even with the name it still generates an error. The following parsing macro is used which requires a ( somewhere after the at. The [ ] part is added using the default value beforehand if it isn't present.

macro:[#1](#2)at#3(->\def \tikz@coordinate@caller {\tikz@fig ode[shape=coordinate,#1](#2)at}\tikz@scan@one@point \tikz@@coordinate@at@math (

So one way to solve this would be to move the ( ) to the outside of the \coord macro. This seems to work, at least in your MWE.

 \tikz \coordinate (name) at (\coord);
 \tikz \node[coordinate] at (\coord) {};
  • My little question is unworthy of this answer! So should I take away from this that it is accidental that \node allows macros to expand into its input syntax, or that it is unintentional that \coordinate is more rigid than it? Depending on the answer to that, what is the right way of using a presupplied at coordinate in a coordinate?
    – Ryan Reich
    Jun 2 '11 at 17:00
  • @Ryan: The expanding while processing \node path is intentionally. The non-expansion of \node coordinate is also intensionally, most likely for efficiency. More macros would be needed otherwise. Besides using coordinate (name) at (\coord); as shown above you could use \edef to expand the command beforehand: \edef\mycommand{\noexpand\coordinate (name) at \coord;}\mycommand.
    – Martin Scharrer
    Jun 2 '11 at 17:03
  • I think I'll go with using \node[coordinate], then, since in fact I don't want to arrange things so that the parentheses are not in \coord. Thanks!
    – Ryan Reich
    Jun 2 '11 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.