[Xy-pic] 'macros' with saved points

Ross Moore ross at ics.mq.edu.au
Tue Nov 4 11:36:56 CET 2003


Hi Scott,

On Mon, 3 Nov 2003, Scott Morrison wrote:

> Ross,
>
> thanks for your help -- but I can't get this to work. Presumably I'm

This draws the circles just fine...
>
> \newcommand{\dropcircle}{\drop\xycircle(2,4){}}
> \newcommand{\dropcircletwo}{\save*\xycircle(2,4){}\restore}
>
> \begin{document}
>
> \begin{equation*}
> \xy
>   *\xycircle(2,4){}; (0,1) *{a}
> \endxy
> \end{equation*}
>
> \begin{equation*}
> \xy
>   \dropcircle; (0,1) *{a}
> \endxy
> \end{equation*}
>
> \begin{equation*}
> \xy
>   \dropcircletwo; (0,1) *{a}
> \endxy
> \end{equation*}

 ... but the parser has been switched off after the \xycircle .

If you want it to remain on afterwards, then use:

> \newcommand{\dropcircle}{\drop\xycircle(2,4){}\POS}
> \newcommand{\dropcircletwo}{\save*\xycircle(2,4){}\restore\POS}

These use \POS to explicitly restart the parser after the high-level
 \xycircle  command has done its thing.


The following also keeps the parser alive:

 \newcommand{\dropcircleone}{\POS{\drop\xycircle(2,4){}}}

whereby the \xycircle is dropped as a "decoration" and the
parser restarted afterwards.


You need to draw the distinction between "high-level" commands
(e.g., \xymatrix,  \xycurve, \xygraph, \xypolygon, etc. )
 --- that do something pretty complicated with the data provided
either *in* their single argument, including any tokens that
lie between the macro-name and the {...} argument

and "low-level" commands, such as \POS, \drop, \save, ...
which do much more fundamental things based upon the tokens which
follow.

The low-level commands turn on the parser, to interpret what follows,
and leave it on until they encounter something outside the set
of specified tokens; e.g. a macro-name other than that of an
Xy-pic <object>  (\dir \txt \cir and a few others with short names).

A high-level command may also need to parse some information,
and may turn-on the low-level parser while doing so. But when
finished, the high-level command typically leaves the parsing off,
for following tokens.
The reason for this is that it's not clear where you want to be
after a high-level command:
either:
   a.  at the same place as where you were before the command;
or
   b.  at the place where drawing ceases;
or
   c.  at the other side of the bounding-rectangle of what the high-level
       command has just drawn.

To see this, try these definitions:
   \newcommand{\dropcircleone}{\POS{\drop\xycircle(2,4){}}}
   \newcommand{\dropcirclethree}{\xycircle(2,4){}\POS}

and compare the diagrams drawn by:

\begin{equation*}
\xy
  \dropcircleone; (0,1) *{a}
\endxy
\end{equation*}


\begin{equation*}
\xy
  \dropcirclethree; (0,1) *{a}
\endxy
\end{equation*}


>
> \end{document}
>
> Thanks, Scott


Hope this helps,

	Ross Moore

>
> _______________________________________________
> xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic
>


More information about the xy-pic mailing list