Mathematicians have been using diagrams of objects and arrows to explain their work since at least 1945.1 Conventionally, these are called commutative diagrams (even when they don't commute2). When publishers first began using TeX, commutative diagrams caused them problems --- I remember being asked by one publisher to turn a commutative triangle into a square by the addition of an equals sign. Fortunately, there are now several very capable packages for producing commutative diagrams. Despite their wide use by mathematicians and others, these packages are barely mentioned in the usual books on TeX. In this guide, I show by means of examples what each package can do, and I provide enough information for you to begin using them. To view the description of a package, click on the link at left.

Except where noted, each package is included in the standard MikTeX installation and can be used without restriction.

There are other packages that can be used to produce commutative diagrams which I haven't looked at. Among those that have been recommended to me are: diagmac2, metapost, pstricks.

Corrections, comments, and tips that can be used to improve future versions of this guide are welcome, and can be sent to me at tex at jmilne.org. I thank Alex Aguado, Stuart Ambler, Joel Friedman, G. Hersh, Richard Lewis, Florêncio Neves, José Carlos Santos, and Bob Tennent for their help.

Summary

It is possible to produce commutative diagrams as arrays, but they are ugly, and so you should only use it for drafts.

The package amscd is very easy to use, but it can produce only simple diagrams (no curved or diagonal arrows; limited arrow shapes).

DCPic is a versatile package based on the graphical engine pictexwd. It supports 11 types of arrows and allows you to curve arrows.

The package diagrams is easy to use, and is the best of the packages at making automatic adjustments. However, it doesn't support curved arrows, the arrow heads don't match those in inline mathematics, and it has a quirky licence.

The package kuvio is very similar to diagrams, but is more versatile in some respects. However, it doesn't work with pdflatex, and it hasn't been revised since 1996.

tikz is a general purpose graphics package that can be used to produce very high quality commutative diagrams, but the code can be complex. The recent package tikz-cd (Florêncio Neves) simplifies the code.

xymatrix is included in the graphic package Xy-pic. Apart from amscd, it is probably still the most popular package. However, its syntax is clumsy, for example,

`\ar@{^{(}->}`
is the code for a hook arrow, and it can take a good deal of fiddling to get its diagrams to come out correctly.

Both tikz and xymatrix are recommended by the American Mathematical Society.

The package diagxy is a front end to Xy-pic that gives you a more precise control over positioning and spacing than xymatrix.

Recommendations

For simple diagrams, amscd is convenient to use. Beyond that, if you are already using one of the graphics packages, then you should first look at the corresponding commutative diagrams package (DCpic for pictexwd, tikz for itself, xymatrix or diagxy for Xy-pic). The packages diagrams and kuvio are also worth looking at.

Personal experience

I have always used amscd for simple diagrams. For several years, I used diagrams for more complicated diagrams because it makes it very easy to produce most commutative diagrams, but eventually stopped mainly because I couldn't get the arrow heads I wanted and because of its licence. I then switched to xymatrix, despite its clumsy syntax, but found myself migrating more to diagxy since it often made it easier to get the quality I wanted. Once I started using tikz to add graphics to my manuscripts, I dropped xymatrix and I began using tikz to produce the commutative diagrams that amscd can't. Finally, with the appearance of tikz-cd I've stopped using amscd and use only tikz.
-------------------------
1Or perhaps 1919.
2A diagram is commutative if the arrows connecting two nodes always compose to the same arrow, independently of the path chosen.