Posted by Jason Polak on 10. March 2015 · 1 comment · Categories: math

The other day I wondered to myself, “am I using the best commutative diagram drawing package available?” Reading a little about Tikz on tex.stackexchange.com got me thinking that there might be improvements in store for my future commutative diagrams. Of course, being an ardent xy-pic fan, I was a bit hesitant. Nevertheless, I decided to try tikz-cd, by making two almost identical commutative diagrams with each package:

xypic tikz

Can you tell which one is which?

Visual Differences

The first one was drawn with xy-pic, and the second with tikz-cd. At many points, they are very similar, but there are some notable differences, the biggest one for me being that the hookrightarrow typesetting (source D) in tikz-cd is vastly superior to the oversized brute of a hook in xy-pic:
oversizedhook

Code Differences

Visual differences aside, which one is nicer to use? Here is the xypic syntax:

Here is the tikz-cd syntax:

The two languages are similar. The basic positions of the nodes, or vertices of the diagram, are specified in the LaTeX matrix syntax, and then \ar commands are used to for arrows. The tikz-cd syntax uses fewer symbols, making the code easier to read for me, though I like the xypic method of specifying an arrow type by symbols that look like the arrow as I’ve often used arrows that I would not have known the name for in LaTeX commands.

Another slightly unfortunate aspect of tikz-cd in my usage is that it specifies labels of arrows via strings in quotation marks. I would have preferred something like putting the label in curly braces, e.g. \ar[d,dotted]{\alpha}, since in the Vim editor with the LaTeX plugin, after a quotation mark autoexpansion of greek letters no longer works. However, there should be a way around this that I’ll take some time one day to discover.

Beyond Commutative Diagrams

It’s worth noting that the tikz-cd package is just a small subset of what tikz can do, and you can mix these vastly more powerful features of tikz into a commutative diagram, or just use whatever you learn about tikz for something else completely. For instance, tikz has a drawing option called ‘draw opacity’. You can pass this option to an arrow, e.g. \ar[r,draw opacity=0.5] to draw an arrow at 50% opacity.

Another example is line width: you can pass the option line width=0.3mm to make an especially thick arrow. However, one should be cautious with changing too many options since diagrams can quickly tend towards looking strange.

1 Comment

  1. I prefer tikz-cd package.When I use xy-pic to draw a diagram with diagonal arrow,the arrow is not straight.I was thinking that there must be wrong in my tex file.But I could not find the mistake.One of my friends told me that tikz-cd package is better than xy-pic.I made the diagram by tikz-cd and it turned out to be better.So I give up xy-pic since then,although xy-pic is a good tool for everyone.

Leave a Reply to Mosbic Cancel reply

Your email address will not be published. Required fields are marked *