TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for something that is the equivalent of \providecoordinate in TikZ/PGFplots. This would be easy if I knew how to test if a coordinate is already defined.

There are similar questions about how to implement something which effectively implements providetikzstyle and how to implement provideenvironment.

share|improve this question
up vote 3 down vote accepted

A coordinate in TikZ is a special form of node. The coordinate x/y etc. values of a node is stored in a macro named \pgf@sh@np@<name> which existence you can test. The following code should do it and support most variations of the \coordinate syntax. Supporting the \path coordinate syntax, i.e. allow for \path providecoordinate is not possible without extensively hacking into the path parsing code.



    \ifcsname pgf@sh@np@#3\endcsname\else


   \providecoordinate [] (A) at (0,0);
   \coordinate (B) at (0,0);

   \providecoordinate (B) at (1,0);

   % Small test: Both at the same location? YES!
   \draw [red]   (A) circle (1pt);
   \draw [green] (B) circle (2pt);

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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