create a diagram of composition of functions

How can I draw the following diagram in latex?

I'd be the first to admit that the syntax looks like line noise, but xy is very fast and you get nice results.

\documentclass[border=5mm]{standalone}
\usepackage[arrow]{xy}
\begin{document}
\begin{xy}
(0,20)*+{A}="a";
(20,20)*+{B}="b";
(0, 0)*+{C}="c";
{\ar         "a";"b"}?*!/_8pt/{f};
{\ar@{>>}    "a";"c"}?*!/^6pt/{g};
{\ar|{\circ} "c";"b"}?*!/^8pt/{h};
\end{xy}
\end{document}


There are a couple of great tutorial papers by Paul Blaga in PracTex here and here.

Two pstricks solutions:

    \documentclass[border=3pt]{standalone}
\usepackage{pst-node, auto-pst-pdf}

\begin{document}

\psset{arrows=->, arrowinset=0.15, linewidth=0.6pt, nodesep=3pt, labelsep=2pt, rowsep=1.2cm}
$\begin{psmatrix} A & B \\% C %%% \ncline{1,1}{1,2}\naput{f} % \ncline[arrows=->>]{1,1}{2,1}\nbput{g } \ncline{2,1}{1,2}\nbput{h}\psset{framesep=-2pt}\ncput*{\pscircle(0,0){3pt}}% \end{psmatrix}$
$\begin{psmatrix} A & B \\% C %%% \ncline{1,1}{1,2}\naput{f} % \ncline[arrows=->>]{1,1}{2,1}\nbput{g } \ncline{2,1}{1,2}\nbput{h}\ncput{\pscircle(0,0){3pt}}% \end{psmatrix}$

\end{document}


Sebastiano's answer is good, but it doesn't replicate exactly what is shown above, probably because he was (as he admits himself) in a hurry. Allow me to contribute my answer (by the way, I am in no way trying to degrade your answer, Sebastiano, I'm just trying to help and add some more details). So here's the code in tikzcd:

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

\begin{document}

$\begin{tikzcd}[column sep=large, row sep=large] A \ar[d, "g"', twoheadrightarrow] \ar[r, "f"] & B \\ C \ar[ru, description, "h"'] \end{tikzcd}$

\end{document}


But sadly, tikzcd doesn't have the circle arrow implemented, so I can't do anything. Thruston already showed the solution with xy package, so I guess I'm left with plain tikz. It is undoubtedly harder but also more flexible than tikzcd or xy. Here's the final code.

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[node distance=2cm, auto]
\node (A) {$A$};
\node(B) [right of=A] {$B$};
\node (C) [below of=A] {$C$};
\draw[->](A) to node {$f$}(B);
\draw[->>](A) to node [left] {$g$}(C);
\draw[->](C) to node [below=0.5ex] {$h$}(B);
\node at (1.0099,-1.002) {$\circ$};
\end{tikzpicture}

\end{document}


• Dear I have only given the input seen because missing also the user MWE. I admit my guilt for the rush but I was hoping that someone appreciated my little work. Personally I vote all positive as I appreciate the help and interest of each of us. Mar 14, 2017 at 20:48
• Yes, I understand. No guilt needed whatsoever. The important thing here is that we got the problem resolved and learned something new ourselves in the process. That's all that matters. Have a good day, sir. Mar 15, 2017 at 12:44

This is a starting point. You could search for symbols with the arrows or \usetikzlibrary{decorations.markings} that you need and the image is made with tikz-cd. I did everything in a hurry. Always I have voted negative just because I go always in a hurry? I appreciate every answer and the positive vote independently. I vote a negative response when it is senseless or off topic.

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

\begin{document}

$\begin{tikzcd} A\ar{r}{f}\ar{d}[swap]{g} & B\\ C \ar{ur}{h} & \end{tikzcd}$
\end{document}

• Whoever downvoted this, please add a comment explaining the reason for the downvote. Mar 14, 2017 at 21:02