# Drawing a particular commutative diagram

I can draw

using

\begin{diagram}
X &\rTo^{\gamma} &Y & \lDotsto & \varepsilon_2\\
\dTo^\alpha  &\ruTo^\beta & & &\\
Z& \lDotsto &\varepsilon_3
\end{diagram}

and the following declarations in the preample

\documentclass{beamer}
\diagramstyle[labelstyle=\scriptstyle]

Can someone please show me how to modify things to obtain the following variant of the original diagram?

Thank you very much!

• Welcome! Please make your code into a compilable example. – cfr May 7 '16 at 3:23
• @cfr Thanks for the tip. Next time I'll do so. – yurnero May 7 '16 at 10:25

If you don't mind using xy-pic, the code

\documentclass{beamer}
\usepackage[all,cmtip]{xy}
\begin{document}
\begin{displaymath}
\xymatrix{
{X} \ar[rr]^{\gamma} \ar[dr]^{\alpha}
&& {Y}\\
{\varepsilon_{3}} \ar[r]
& {Z} \ar[ur]^{\beta}
& {\varepsilon_{2}} \ar[u]
}% xymatrix
\end{displaymath}

\end{document}

will produce

For a tutorial on commutative diagrams using xy-pic, see section 8 of "Getting up and running with AMS-LaTeX", at https://www.ctan.org/tex-archive/info/amslatex-primer?lang=en

Here is the diagram with diagrams.sty; I drew the version with the standard arrow along with the head=littlevee version. The latter has disastrous results.

\documentclass{article}
\usepackage[small,nohug]{diagrams}
\diagramstyle[labelstyle=\scriptstyle]

\begin{document}

\begin{diagram}
X             &              & \rTo^{\gamma} &             & Y \\
& \rdTo^\alpha &               & \ruTo^\beta & \uTo \\
\varepsilon_3 & \rTo         & Z             &             & \varepsilon_2
\end{diagram}

\begin{diagram}
X             &              & \rTo^{\gamma} &             & Y \\
& \rdTo^\alpha &               & \ruTo^\beta & \uTo \\
\varepsilon_3 & \rTo         & Z             &             & \varepsilon_2
\end{diagram}

\end{document}

I recommend using tikz-cd instead. The syntax is much easier and the result much prettier.

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

\begin{document}

\begin{tikzcd}
X \arrow[rr,"\gamma"] \arrow[dr,"\alpha"] && Y \\
\varepsilon_3 \arrow[r] & Z \arrow[ur,"\beta"] & \varepsilon_2 \arrow[u]
\end{tikzcd}

\end{document}

Here is the tikz-cd version with dotted arrows.

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

\begin{document}

\begin{tikzcd}
X \arrow[rr,"\gamma"] \arrow[dr,"\alpha"] && Y \\
\varepsilon_3 \arrow[r,dotted] & Z \arrow[ur,"\beta"] & \varepsilon_2 \arrow[u,dotted]
\end{tikzcd}

\end{document}

• Where to get diagrams.sty? Not available on ctan.org – pzorba75 May 7 '16 at 17:26
• @pzorba75 Indeed, it is only available on Paul Taylor's web site: paultaylor.eu/diagrams – egreg May 7 '16 at 17:28
• Although the diagrams package produces fine output, it contains a "time bomb" that renders the package unusable after a date preset by the author, so a new version has to be retrieved. If the input for the project for which it is being used is expected to remain viable indefinitely, diagrams isn't the best package to choose. – barbara beeton Oct 8 '20 at 16:24
• @barbarabeeton I fully agree. – egreg Oct 8 '20 at 17:27

LaTeX's built-in picture command isn't bad, though the trial-and-error to get things placed correctly is inconvenient. To get the following, use the code below.

\documentclass[11pt]{article}

\begin{document}

\setlength{\unitlength}{1pt}
\begin{picture}(150,50)
\put(0,0){$\varepsilon_3$} \put(70,0){$Z$} \put(140,0){$\varepsilon_2$}
\put(0,40){$X$} \put(140,40){$Y$}
\put(12,3){\vector(1,0){55}} \put(143,10){\vector(0,1){27}}
\put(13,38){\vector(2,-1){55}} \put(82,10){\vector(2,1){55}}
\put(13,43){\vector(1,0){120}}
\put(70,48){$\gamma$} \put(45,25){$\alpha$} \put(96,25){$\beta$}
\end{picture}

\end{document}

Here are two solutions: one with  pstricks, the other with tikz-cd:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usepackage{auto-pst-pdf}

\begin{document}

With \texttt{pstricks}: $\psset{arrows=->, arrowinset=0.2, linewidth=0.5pt, nodesep=2pt, labelsep=2pt, rowsep=0.8cm, colsep=1cm, shortput=tab, linejoin=1} \everypsbox{\scriptstyle} \begin{psmatrix} %%%nodes X & & Y\\% \varepsilon _3 & Z & \varepsilon _2 %%% %%% arrows \ncline{1,1}{1,3}^{\gamma } \ncline{1,1}{2,2}^[tpos = 0.6]{\alpha } \ncline{2,1}{2,2} \ncline{2,2}{1,3}^[tpos = 0.36]{\beta } \ncline{2,3}{1,3} \end{psmatrix}$

With \texttt{tikz-cd}: $\begin{tikzcd}[column sep=0.6cm] X \arrow{rr}{\gamma }\drar{\alpha } & &Y \\% \varepsilon _3 \rar & Z \urar[pos = 0.42]{\beta } & \varepsilon _2 \uar \end{tikzcd}$

\end{document}

I don't know the diagram environment but for commutative diagrams I recommend using tikz package and a matrix of math nodes to give:

Here is the code:

\documentclass[border=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{center}
\begin{tikzpicture}[>=stealth,->,shorten >=2pt,looseness=.5,auto]
\matrix (M)[matrix of math nodes,row sep=1cm,column sep=16mm]{
X             &   & Y\\
\varepsilon_3 & Y & \varepsilon_2\\
};
\draw(M-1-1)--node{$\gamma$}(M-1-3);
\draw(M-1-1)--node{$\alpha$}(M-2-2);
\draw(M-2-2)--node{$\beta$}(M-1-3);
\draw(M-2-1)--(M-2-2);
\draw(M-2-3)--(M-1-3);
\end{tikzpicture}
\end{center}
\end{document}

I think the code is mostly self-explanatory, although familiarity with tikz will of course help:) One less obvious part, perhaps, is that the (M) in \matrix (M) says that the matrix coordinates should be referred to using the letter M together with the row and column indices. So if you instead had \matrix (mat) then you would refer to the coordinates as (mat-1-1), (mat-1-2) etc.

There is also a tikzcd package but my simple mind cannot cope with the syntax it requires:)

• the arrow at bottom left should be horizontal. it's slightly tilted upward. – barbara beeton May 7 '16 at 16:11
• @barbarabeeton Yes, you're right. The arrow goes between the centers of the corresponding nodes so it is not horizontal because \varepsilon_3 and Y have different heights. This is clearly not what is wanted, but I do not see an easy fix. One way out is to add \rlap{\phantom{$Y$}} to the node but there ought to be a better way... – user30471 May 8 '16 at 23:03
• you might just add \mathstrut to the \varepsilon node. not wonderful, but a bit more direct and scrutable than using a phantom (which, strictly speaking, should be \vphantom, which doesn't need an \rlap). – barbara beeton May 9 '16 at 1:36