Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

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

1 Answer 1

up vote 7 down vote accepted

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”.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.