[Xy-pic] Using macros in xymatrix

Ross Moore ross at ics.mq.edu.au
Sun Jul 29 06:59:50 CEST 2007

On 27/07/2007, at 1:22 AM, Andrew Clegg wrote:

> \lab{foo} \arr{r}|\lab{bar}
> But this doesn't work! I get an "Argument of \lab has an extra }"
> message as if something fragile is getting expanded improperly.

Within Xy-pic parsing, the above coding is equivalent to:

    \lab{foo} \arr{r}|{\lab}{bar}

since the | looks at only the next token.
Only if this is an opening brace '{' or a '*' does it
read further to find the full label to place.

Also, if it is an opening parenthesis '(' then it needs
to read the parameter location for the <break> in the arrow.
And a '-' sign also affects the way the location is determined.

If the token is anything other than these special cases,
then it is treated as the complete label to be placed
in the default location. Hence you get effectively  |{\lab}
and then TeX complains about not being able to find the #1
token for \lab when it is ultimately expanded.

This explains the error message that you saw.

> Does anyone have a workaround, or a better way to solve the problem
> without using \newcommand?

You know how to do it correctly now.

This message is to complete the earlier explanations,
by saying why TeX does what it does with the incorrect syntax.

> Many thanks,

Hope this helps,


> Andrew.

Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114

More information about the xy-pic mailing list