[Xy-pic] Showing an arrow in text

Ross Moore ross.moore at mq.edu.au
Sat Jan 25 01:02:46 CET 2014

Hello Josep, Kris Rose and others,

On 25/01/2014, at 9:44 AM, Josep Maria Font wrote:

> Just to report on the solution of the problem below, courtesy of Philip Hirschhorn.
> After some experimenting, it seems that the error appears in minimal examples, but only when the offending \xymatrix occurs in the argument of a \caption{...} (the original situation) or of a \section{...} commands.

Is this any different to when using other *fragile* commands within such a setting?
(Yes it is; see further down!)

This works fine for me:

   \caption{The arrow $\protect\xymatrix at C=10pt{*{}\protect\ar[r]&*{}}$ is nice.}

except ...

> Encapsulating the whole \xymatrix into a user-defined command, and using it in such places together with a \protect command in front of it solved the issue.

  ... when  \listoffigures  is actually called.

Now the problem becomes one of the category code of '@'.

viz. we have this line in the  .lof  file:

\contentsline {figure}{\numberline {1}{\ignorespaces The arrow $\xymatrix @C=10pt{*{}\ar [r]&*{}}$ is nice.}}{1}

But when the .lof file is input the category code of '@' is 11;

\listoffigures ->\@starttoc {lof}\listfigurename 

\@starttoc #1#2->\begingroup \setTrue {#1}\par \removelastskip \vskip \z at skip \
@startsection {}\@M \z@ {\linespacing \@plus \linespacing }{.5\linespacing }{\c
entering \contentsnamefont }{#2}\ifx \contentsname #2\else \addcontentsline {to
c}{section}{#2}\fi \makeatletter \@input {\jobname .#1}\if at filesw \@xp \newwrit
e \csname tf@#1\endcsname \immediate \@xp \openout \csname tf@#1\endcsname \job
name .#1\relax \fi \global \@nobreakfalse \endgroup \addvspace {32\p@ \@plus 14
\p@ }\let \tableofcontents \relax 

See those commands:  \makeatletter \@input {\jobname .#1} 

This is presumably because many packages, and LaTeX itself, 
can write internal commands into auxiliary files, where @ is part
of the command name.

Unfortunately, this will kill Xy-pic's parsing of:  \xymatrix @C=10pt

\xymatrix at setup ->\ifx \space@ \next 
 \expandafter \DN@ \space {\xyFN@ \xymatrix at setup }\else 
 \ifx \bgroup \next \let \next@ =\xymatrix at ii \else 
 \addAT@ \ifx \next \addAT@ \DN@ {\xy@ {@}{}\xyFN@ \xymatrix at at }\else 
 \ifx "\next \let \next@=\xymatrix at prefix \else 
 \DN@ {\xyerror@ {\string \xymatrix <setup>{<rows>} expected}{}}%
 \fi \fi \fi \fi \next@ 
{false} % <--- next character is not a space
{false} % <--- next character is not a '{'

\addAT@ #1->#1@
{false} % <--- next character is not an '@'-symbol
{false} % <--- next character is not a '"'

 ... but the next character is an '@'-letter !!!

[to Kris Rose: 
  we need an extra line or two here in \xymatrix at setup 
  to cope with this possibility, which isn't that unusual!

> It is not clear *why* this happens, anyway (the error mentions \xP at doSpecialRotate@@).

Your solution of defining the Xy-pic coding as the expansion of 
a macro is the best solution,
(which must come *before*  \listoffigures  is called; e.g. in the preamble)
provided either:

 a.  you call that macro with  \protect inside a \caption  or  \section

 b. use  \DeclareRobustCommand  to make the macro definition.
    Now the  \protect  is not unnecessary.

\DeclareRobustCommand{\myxycaption}{\xymatrix at C=10pt{*{}\protect\ar[r]&*{}}}

\caption{The arrow $\myxycaption$ is nice.}

> Best,
> JMaF

Hope this helps,


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo.png
Type: image/png
Size: 5257 bytes
Desc: not available
URL: <http://tug.org/pipermail/xy-pic/attachments/20140125/2c58c281/attachment.png>
-------------- next part --------------

More information about the xy-pic mailing list