5

M(non-)WE:

\documentclass{article}
\usepackage[all]{xy}
\begin{document}
\[ \xymatrix{ \overrightarrow{C} } \]
\end{document}

produces "ERROR: Illegal parameter number in definition of \lastprentry@@.". Any ideas?

1
  • For me, adding \usepackage{amsmath} fixes things: I suspect this is simply assumed by xy.
    – Joseph Wright
    Jul 12, 2014 at 7:30

1 Answer 1

7

Add braces around the symbol, which is often the remedy to weird error messages from Xy-pic macros:

\documentclass{article}
\usepackage[all]{xy}
\begin{document}
\[ \xymatrix{ {\overrightarrow{C}} } \]
\end{document}

Or just add an empty group:

\documentclass{article}
\usepackage[all]{xy}
\begin{document}
\[ \xymatrix{ {}\overrightarrow{C} } \]
\end{document}

The problem is that \overrightarrow, being the first item in an alignment cell, gets expanded to

\vbox{\m@th\ialign{##\crcr <...>}

and this confuses the parsing commands of Xy-pic. This doesn't happen if a brace is found before \overrightarrow, because it will be expanded later. This doesn't happen also when amsmath is loaded, because the definition of \overrightarrow given by amsmath is “safer”.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .