How can I write a macro that returns a coordinate (or a node). The node must be usable within a tikzpicture environment and preferably inside a path declaration.
I need something like the following (it doesn't compile). I am not sure if pgfcoordinate is the correct way to go...
\documentclass{article}
\usepackage{tikz}
\usepackage{pgf}
\begin{document}
\newcommand{\mycoord}[2]{
\pgfmathsetmacro{\x}{\pgfmathparse{#1} \pgfmathresult} % actually do some calculations
\pgfmathsetmacro{\y}{\pgfmathparse{#2} \pgfmathresult} % actually do some calculations
\pgfcoordinate{\x}{\y}} % I want this node to be returned.
\begin{tikzpicture}
\node at \mycoord{1}{2} {some text}; % I want to use the calculated node
\end{tikzpicture}
\end{document}
the error message is
Package tikz Error: Cannot parse this coordinate.
mycoordwithin the tikzpicture environment. Preferably within a path. – pmav99 Jun 06 '11 at 16:33pgfcoordinatein wrong way. The definition is\pgfcoordinate{⟨name ⟩}{⟨coordinate ⟩}. The first argument must be a name. Then when you use\node atyou need to give something that can be parsed like coordinate. I add another example in my answer – Alain Matthes Jun 06 '11 at 18:48