# TeX4ht: Strange behavior when I include \xymatrix in a macro

See the following code:

\documentclass{amsart}

\usepackage[matrix,arrow,curve,cmtip]{xy}

\begin{document}
\newcommand\test{
\xymatrix{{a} \ar^-{b}[r] & {c} \ar@<0.7ex>^-{d}[r]\ar@<-0.7ex>_-{e}[r] & {f}}
}
\tracingmacros=1
Compare
$\test$
and
$\xymatrix{{a} \ar^-{b}[r] & {c} \ar@<0.7ex>^-{d}[r]\ar@<-0.7ex>_-{e}[r] & {f}}$
\end{document}


It is very weird that if I put \xymatrix part in a macro as above, then tex4ht will generate messy pictures. I look for a workaround of this.

The issue is with superscripts, as they are patched by tex4ht at \begin{document}. Your sample compiles correctly when you move definition of the \test macro before \begin{document}. Another possibility is to use the no^ and no_ command line options, but this may broke other things.

% https://tex.stackexchange.com/q/499677/2891
\documentclass{amsart}

\usepackage[matrix,arrow,curve,cmtip]{xy}

\newcommand\test{%
\xymatrix{{a} \ar^-{b}[r] & {c} \ar@<0.7ex>^-{d}[r]\ar@<-0.7ex>_-{e}[r] & {f}}
}

\begin{document}
\tracingmacros=1
Compare
$\test$
and
$\xymatrix{{a} \ar^-{b}[r] & {c} \ar@<0.7ex>^-{d}[r]\ar@<-0.7ex>_-{e}[r] & {f}}$
\end{document}