Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Can anyone help me in giving commands for commutative diagrams in LaTeX ? It doesn't seem to appear properly in the LaTeX guides that I have. A command for a simple triangular diagram with arrows associated to maps would be good enough, or maybe some appropriate reference.

share|improve this question
2  
sure, how about a quick google –  cmhughes May 23 '13 at 15:28
2  
Take a look at jmilne.org/not/CDGuide.html –  Papiro May 23 '13 at 15:29
    
One single authentic source on xy-pic is at TUG and its userguide and crisp Introduction ppt. More in depth reference guide –  texenthusiast May 23 '13 at 15:34
4  
The most modern package is tikz-cd. The documentation includes numerous examples. –  Gonzalo Medina May 23 '13 at 15:38

2 Answers 2

up vote 9 down vote accepted

For simple and complex diagrams, I'd recommend tikz-cd. Let's see an easy triangular diagram.

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\[
\begin{tikzcd}
A \arrow{r}{f} \arrow[swap]{dr}{g\circ f} & B \arrow{d}{g} \\
& C
\end{tikzcd}
\]
\end{document}

enter image description here

An arrow takes as argument the "steps" where it has to go: r stands for "right", d stands for "down"; also u stands for "up" and l for "left".

A similar syntax is available with Xy-pic.

\documentclass{article}
\usepackage[all,cmtip]{xy}
\begin{document}
\[
\xymatrix{
A \ar[r]^{f} \ar[dr]_{g\circ f} & B \ar[d]^{g} \\
& C
}
\]
\end{document}

Note how the labels are positioned: ^ means above the arrow, _ means below; above and below are with respect to the direction of the arrow: rotate it counterclockwise until it points from left to right.

enter image description here

As you see, the results are pretty much alike. While I used to use Xy-pic, I'm now more convinced that tikz-cd can be better, as it relies on the powerful TikZ/PGF library.

share|improve this answer
    
Thanks, that's very helpful :) –  smiley06 May 25 '13 at 8:30

Another way is to use the psmatrix environment, from pst-node. The objects are firstdescribed as nodes in a matrix, then the arrows are described. In this description, nodes can be given a name, or are described by their pair of indices i, j in the matrix. See documentation of pst-node for details on how to connect nodes or more generally how to fine-tune the look of a diagram.

You can compile with pdflatex if you use the --shell-escape switch (TeX Live, MacTeX) or --enable-write18 (MiKTeX), and use the pdf option for the document class: this loads the auto-pst-pdf package. Alternatively, you can load the latter package, after pstricks and its family.

Here is a simple example:

\documentclass[pdf]{article}
\usepackage{pst-node}

\begin{document}

\[ \psset{arrows=->, arrowinset=0.25, linewidth=0.6pt, nodesep=3pt, labelsep=2pt, rowsep=1.2cm}
\begin{psmatrix}
  (X, d) & (X_1 ,d_1 )\\%
   & (X_2 ,d_2)
%%%
 \ncline{1,1}{1,2}\naput{T_1} \ncline{1,1}{2,2}\nbput{T_2 }
 \ncline{1,2}{2,2}\naput[npos=0.45]{T}
\end{psmatrix}
\]
\end{document} 

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.