# [Xy-pic] Bug report by Radionov: solution

Johann Bauer jbauer-news at web.de
Thu Mar 22 09:39:40 CET 2007

Last month, Vadim Yu. Radionov reported a bug, where an arrowhead pointed in the wrong direction. Contrary to the first guess, the problem is not related to the xy code for curves but lies in the core xy.tex:

The macro \setupDirection at ii computes the \Direction number from given offets \d at X and d at Y (line 7170 ff. in xy.doc). Usually, one of the two conditions in lines 7188 and 7194 is fulfilled, but due to numerical inexactness this is not always the case. Exactly this happened in the example file, where \d at X and \d at Y were very small and the direction was near the diagonal.

The code in lines 7200 to 7205 is obviously written in order to deal with this exception but it does not do its job very well. My suggestion is to replace this code

\ifnum\Direction=\maxdimen
\Direction=\K at dYdX \advance\Direction-\K at dXdY
\fi

by

\ifnum\Direction=\maxdimen
\Direction=\K at dYdX \advance\Direction\K at dXdY
\fi

in xy.doc (and xy.tex, of course). To see the difference, compile the following example with the old xy.tex and my replacement. All arrowheads should point along the curves in counterclockwise direction.

Regards, Johann

\documentclass{minimal}
\usepackage[curve]{xy}
\begin{document}
$\xy (0,0); (13,0) *{} **\crv{(6.5,-8.5)} ?(.88) *\dir{>}, (14,1); (14,14) *{} **\crv{(22.5,7.5)} ?(.88) *\dir{>}, (13,15); (0,15) *{} **\crv{(6.5,23.5)} ?(.88) *\dir{>}, (-1,14); (-1,1) *{} **\crv{(-9.5,7.5)} ?(.88) *\dir{>}, \endxy$
\end{document}