Michael Barr barr at math.mcgill.ca
Fri May 9 15:07:43 CEST 2008

I am not entirely certain what you are trying to do, but I would like to
offer the following code from my diagram making macros:

\def\node#1(#2,#3)[#4]{%
\expandafter\gdef\csname x@#1\endcsname{#2}%
\expandafter\gdef\csname y@#1\endcsname{#3}%
\expandafter\gdef\csname ob@#1\endcsname{#4}%
\ignorespaces}%

What this code does is to take something like
\node a(30,40)[A]
and define three macros whose definitions are equivalent to
\gdef\x at a{30}
\gdef\y at a{40}
\gdef\ob at a{A}

There are several things to note.  First, \newcommand will not work.  Of
course, if I used it as
\node {a}{30}{40}{A}
it would, but I don't much like all those braces (and most parts of the
diagram macros cannot be coded using \newcommand either.  I use \gdef
because this appears inside another macro; I don't think there is a
\newcommand equivalent.  Finally, the node names don't have to be letters
only.  I could (and regularly do) use things like
\node 3c(30,40)[A]
since the form
\expandafter \csname ??? \endcsname {definition}
allows any string of characters as a control sequence name.  Of course,
when calling these macros, the same thing has to be done.  These macros
are used in the following form:
\morphism(\csname x@#3\endcsname,\csname y@#3\endcsname)|#1|/{#2}/%
<\xfinish,\yfinish>[\csname ob@#3\endcsname\csname ob@#4\endcsname;#5]%
}%
An earlier implementation of this used two counters for each node.  This
one uses just two counters, since the numerical values are stored as
macros, not counters and just  two temporary counters are used for a whole
diagram.  This is important since tex puts a severe restriction on the
number of counters (256, of which several dozen are used by latex alone)
while the number of macros is effectively unlimited (my tex implementation
reports that there are 10000 + 50000, which I don't understand, but 5000
is what I typically use).

I hope this helps.

Michael Barr
`