[Xy-pic] \xybox's in \align

Ross Moore ross at ics.mq.edu.au
Thu Nov 6 01:58:47 CET 2003

Hi Scott,

On Wed, 5 Nov 2003, Scott Morrison wrote:

> For some reason,
> \begin{equation}
> \xybox{(0,-4.)*\xybox{(1.5,8);(1.5,0) **\crv{(2.5,2.4)&(0.5,5.6)},
> }}
> \end{equation}
> works fine, producing a squiggly line, but
> \begin{align}
 \relax \xybox{(0,-4.)*\xybox{(1.5,8);(1.5,0) **\crv{(2.5,2.4)&(0.5,5.6)},
 |||||| ---------   try this!

> }}
> \end{align}
> fails, generating the error
> ! Argument of \next@ has an extra }.
> <inserted text>
>                  \par
> l.537 \end{align}

> Does anyone know why? What's going on here?

Yes; this is a common problem whenever you have an alignment
environment based on TeX's \halign or \ialign primitives.

The explanation is that for every cell TeX needs to "look ahead"
to see whether there is an \omit or \span  primitive coming next,
perhaps as a result of expanding any other macros.
(In LaTeX these come from \multicolumn \noalign and suchlike.)

Thus if the 1st token in any cell (i.e. at the start
or following any & or \\ ) is expandable, then it *must* be
expanded to see what is really coming next.

Since \relax is a primitive (which does nothing) then it
fulfills the look-ahead requirement, and doesn't cause the
\xybox to act too soon.

Note that \relax *cannot* be included as part of the
expansion of \xybox as this would upset things like
  \drop\xybox...{...    \xy*\xybox...{...

So you just have to remember to put in the \relax explicitly.
(And yes, there *is* a note on this in the Reference Manual,
in the section on \xymatrix  --- which is based upon \ialign .
It doesn't specifically mention other aligned environments,
but the problem is the same.)

> (the xypic code is a little strange because I'm using Mathematica to
> automatically generate xypic code, using lots of nested xyboxes)

Way to go!
Can you show us some examples?

Having it add the \relax shouldn't be too hard.



> Thanks, Scott Morrison
> _______________________________________________
> xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic

More information about the xy-pic mailing list