To draw a picture using TikZ, we use the tikzpicture environment. This environment can be used in math mode without problems.

In the picture we first define a matrix with the vertices of the commutative diagram (using \matrix). Then we draw the arrows and label them (using \path).

For the matrix, we give a name (m) and several options (the part in square brackets). Then we define the matrix like in the math command of that name (except that it is important to finish the last line with \\). The options do the following things:

matrix of math nodes tells TikZ to interpret the code in the actual matrix in math mode (without it, TikZ would want to get drawing commands in the matrix).

row sep and column sep set how much the the rows/columns should be spaced apart.

text height and text depth set just that. This is useful for TikZ to figure out where the center of each cell should be (otherwise it would just center them in the apparent center, which is lower for x than for x').

(m-i-j) accesses the cells of the matrix (labeled like in mathematics).

A line is inserted with (start position) edge (end position).

We want to add labels to the arrow. For this we use the node syntax. It inserts a node (=label) in the middle of the edge (or above, below,... it, depending on the options) with the text in curly brackets in it.

Every drawing command must be finished with a semicolon ;.

By default TeX puts the image on top of the baseline. We don't want that, because then the equation counter “(1)” wouldn't be centered. We use the baseline option to tell TikZ where the baseline of the surrounding text should be with respect to its internal coordinate system. As we didn't specify the position of the matrix, it's center is at (0,0) in TikZ's internal coordinate system. So baseline=0 would center the matrix around the baseline of the text/equation. This is better, but still not quite what we want, as we want the center to be on the centerline, i.e. on the height of the middle of the 1. So we move it up by 0.8ex, which corresponds to telling TikZ that the baseline should be at 0.8ex below 0.

As egreg points out, for the centering one could also use gathered from amsmath instead of baseline shifting.

Thanks ! I tried with TikZ, have some good result, but with @egreg's answer the eq. number is properly centered.
–
Cedric H.Apr 25 '11 at 20:35

@Cedric: You can change the anchoring of a TikZ diagram by using the option "baseline". For example, "\begin{tikzpicture}[baseline = (current bounding box)]" begins a vertically centered picture (this is suggested by the manual, somewhere).
–
Ryan ReichApr 25 '11 at 20:42

@Cedric: I didn't see your comment when typing the expanded answer. Well, just ignore everything except the last point then...
–
CaramdirApr 25 '11 at 20:47

The gathered environment is used for centering correctly the equation number. If you really need longer horizontal arrows, write something like \xymatrix@C+12pt instead of \xymatrix (the +12pt is the extra length).

Great ! Is there a way to stretch the whole diagram to make it say 150% bigger ?
–
Cedric H.Apr 25 '11 at 20:45

@Cedric: put \xymatrix{...} inside \scalebox{1.5}{\xymatrix{...}}, but I wouldn't recommend this. Rather use the @C and @R tricks to extend the arrows: for instance \xymatrix@C+24pt@R+12pt will lengthen horizontal arrows by 24pt and vertical arrows by 12pt
–
egregApr 25 '11 at 20:58