# Using symbols for products in xy-pic

I am trying to make a diagram in xy-pic with the xy-matrix environment where I need to have a node which is product of sets like, but I always seem to get a compilation error when I try to use the command for products within an xymatrix environment:

\documentclass{memoir}
\usepackage{kpfonts}
\usepackage[all]{xy}
\CompileMatrices
\usepackage{amssymb,amsmath,amsfonts}
\begin{document}
$$\xymatrix{ \prod_{i:I} A_i \ar@<-.5ex>[r]_c \ar@<.5ex>[r]^d & \prod_{j:J} A_j }$$
\end{document}


But when I try to compile this I get the error:

! Undefined control sequence.
<argument> ...COORD@ =\xymatrixCOORD@ \prodop \kp
@slimits _{i:I} A_i \ar @<...
l.19 \xy@{\save }{\save@ }
%


Any help with how to get this working is much appreciated since I haven't been able to find anyone here with similar problems.

EDIT: After having messed around with the code, it seems like the error arises because of the \CompileMatrices command in the preamble.

• Erh, if you start by making this into a real doc with \begin{document} in its proper place and adding say \documentclass{article}, then your MWE compiles for me. What exactly is your question? – daleif Jan 18 '17 at 12:03
• After adding \documentclass{article} and moving \begin{document} to the proper place, I get no error from the example. The error message suggests you're using the kpfonts package: please make a better example. – egreg Jan 18 '17 at 12:16

From the documentation of Xy-pic:

## 1.7 Speeding up typesetting

One thing that you will notice is that Xy-pic is sometimes slow in typesetting diagrams (this is to be expected considering the number of drawing operations performed as reflected by the number last in each xymatrix message). If you follow the rule of starting all entries with a (nonexpandable) character or { then you can insert the declaration

\CompileMatrices


in the preamble of your document: this will create temporary files containing compiled versions of each matrix that can be loaded very quickly; they are automatically recreated when a matrix is changed.

I added the boldface for emphasis.

\documentclass{memoir}
\usepackage{kpfonts}
\usepackage[all]{xy}
\CompileMatrices
\usepackage{amsmath}
\begin{document}
$$\xymatrix{ \relax\prod_{i:I} A_i \ar@<-.5ex>[r]_c \ar@<.5ex>[r]^d & \relax\prod_{j:J} A_j }$$
\end{document}


On the other hand, compiling matrices is nowadays unnecessary, as machines are fast enough.

Alternative:

\documentclass{memoir}
\usepackage{kpfonts}
\usepackage[all]{xy}
\CompileMatrices
\usepackage{amsmath}
\begin{document}
$$\xymatrix{ {\prod_{i:I} A_i} \ar@<-.5ex>[r]_c \ar@<.5ex>[r]^d & {\prod_{j:J} A_j} }$$
\end{document}


By the way, loading amssymb and amsfonts along with kpfonts is unnecessary, because the package will override them anyhow.