# How to draw commutative diagram? [duplicate]

I'm a Latex beginner, could you please help me to draw these diagrams? Thank you very much!

Use tikz.

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\foreach \x in {1,...,4}
{
\foreach \y in {1,...,3}
{
\draw[->] (2*\x-1,2*\y+0.5)--(2*\x,2*\y+0.5);
\draw[->] (2*\y+0.5,2*\x) --(2*\y+0.5,2*\x-1);
\draw(1,2*\y+0.5) node[left]{0} (8,2*\y+0.5) node[right]{0};
\draw(2*\y+0.5,1) node[below]{0} (2*\y+0.5,8) node[above]{0};
}
}
\draw (2.5,6.5) node{A};
\draw (4.5,6.5) node{B};
\draw (6.5,6.5) node{C};
\draw (2.5,4.5) node{X};
\draw (4.5,4.5) node{Y};
\draw (6.5,4.5) node{Z};
\draw (2.5,2.5) node{U};
\draw (4.5,2.5) node{V};
\draw (6.5,2.5) node{W};
\end{tikzpicture}
\end{document}

• How to get the numbers (1), (2), (3) below the diagram and (a), (b), (c) to the right of the digram? Sep 30 '18 at 3:58
• Just use e.g. \draw (2.5,0) node{(1)}; Adjust the coordinates to wherever you want them.
– JPi
Sep 30 '18 at 3:59
• How to draw the second diagram above? Sep 30 '18 at 4:12
• @Success How about you try drawing it yourself with the answer given, rather than asking someone else to do it for you? Sep 30 '18 at 4:46

Just for fun. (Saw Henri's comment just now, and agree with it.)

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
$\begin{tikzcd}[sep = large] & 0 \ar[d] & 0 \ar[d] & 0 \ar[d] & & \\ 0 \ar[r] & A \ar[d]\ar[r] & B \ar[d]\ar[r] & C \ar[d]\ar[r] & 0 & (a) \\ 0 \ar[r] & X \ar[d]\ar[r] & Y \ar[d]\ar[r] & Z \ar[d]\ar[r] & 0 & (b)\\ 0 \ar[r] & U \ar[d]\ar[r] & V \ar[d]\ar[r] & W \ar[d]\ar[r] & 0 & (c)\\ & 0 & 0 & 0 & \\ \end{tikzcd}$

% see https://tex.stackexchange.com/a/407278/121799
$\begin{tikzcd}[sep = large,every matrix/.append style={name=mycd},remember picture] A \ar[r,"f"]\ar[d,"\alpha",swap] & B \ar[r,"g"]\ar[d,"\beta",swap] & C \ar[d,"\exists\gamma",dashed] \\ U \ar[r,"h"]& V \ar[r,"k"]& W \\ \end{tikzcd}$
\begin{tikzpicture}[overlay,remember picture]
\node at (barycentric cs:mycd-1-1=1,mycd-2-1=1,mycd-1-2=1,mycd-2-2=1) {(I)};
\node at (barycentric cs:mycd-1-3=1,mycd-2-3=1,mycd-1-2=1,mycd-2-2=1) {(II)};
\end{tikzpicture}

\end{document}