# \xymatrix undefined

I am trying to use xy package to draw some diagrams. So I use the command \usepackage{xy} and I type a sample as follows:

\xymatrix{
A &*+[F]{\sum_{i=n}^m {i^2}} \\
& {\bullet} & D \ar[ul] }


But this fails with the error undefined control sequence \xymatrix

I don't understand why. Someone can help me?

-
Welcome to TeX.SX. A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}) or select your code and hit Ctrl+K. Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Claudio Fiandrino Feb 18 '13 at 14:45

You need to load the package xy with the all option:

\documentclass{article}

\usepackage[all]{xy}

\begin{document}
\xymatrix{
A &*+[F]{\sum_{i=n}^m {i^2}} \\
& {\bullet} & D \ar[ul] }
\end{document}


To quote from the documentation:

With LATEX 2e, used by most users, XY-pic is loaded with \usepackage[all]{xy} in the preamble of the document; this also automatically loads an appropriate "backend driver" for generating graphics in either PDF or PostScript format, when possible (by checking for document class options like pdftex, dvipdfm, or dvips), to ensure the highest output quality (and usually results in smaller files).

-
Yes it works. Thanks a lot! –  mapping Feb 18 '13 at 15:24
By chance, I want to push the diagram in the center, so how can I do this? –  mapping Feb 18 '13 at 15:54
You can put it inside a display math environment, e.g. \begin{displaymath} \xymatrix... \end{displaymath}. A number version would be given by an equation environment. The amsmath package provides several more environments that can be used. –  Andrew Swann Feb 18 '13 at 16:47