[Tex/LaTex] How to draw commutative diagrams in LaTeX?


I would like to learn to make commutative rectangles using Tikz. How can I do that? I have tried

A \arrow{r}{\varphi} \arrow[swap]{dd}{g\circ f} & B \arrow{d}{g} \\
& C

but it draws only a triangle.

Best Answer

I don't know what you exactly wanted to draw, so I reproduce one of the diagrams from your link, showing how to do it with pst-node and with tikz-cd. One of the main differences is that in pstricks you first describe the nodes, then the arrows, while with tikz-cd, nodes and arrows are described simultaneously.

I load auto-pst-pdf, as pdflatex doesn't support postscript instructions. You have to set the --enable-write18 compiler switch (MiKTeX) or -shell-escape (TeX Live, MacTeX). Alternatively, you can compile with xelatex.


 \[ \psset{arrows=->, arrowinset=0.25, linewidth=0.6pt, nodesep=3pt, labelsep=2pt, rowsep=0.7cm, colsep = 1.1cm, shortput =tablr}
 A & B\\%
 A_f & B_g
 \ncline{1,1}{1,2}^{\varphi} \ncline{1,1}{2,1} <{\varrho_f }
 \ncline{1,2}{2,2} > {\varrho_g}

\[ \begin{tikzcd}
A \arrow{r}{\varphi} \arrow[swap]{d}{\varrho_f} & B \arrow{d}{\varrho_g} \\%
A_f \arrow{r}{\varphi_f}& B_g

enter image description here

Related Question