# Commutative diagram with upward arrows outside

I have the following code:

\documentclass[a4paper, 12pt]{article}
\usepackage{amsmath, amstext,  amssymb, amsfonts, amsthm, euscript}
\usepackage{tikz-cd}
\usetikzlibrary{babel}

\begin{document}
$\begin{tikzcd} TM \ar[r, "{\rm d}f"] \ar[d, "\pi"] & TN \ar[d, "\pi"] \\ M \ar[ur, shift right = .25ex, "{\rm d}f \circ X"] \ar[ur, shift left = .25ex, "Y \circ f"] \ar[r, "f"] \ar[u, bend left = 50, "X"] & N \ar[u, bend right = 50, "Y"] \end{tikzcd}$
\end{document}


which produces:

I know very little of tikz-cd and I can do only simple triangle and square diagrams. I'd like to have:

• a bigger diagram, with everything more spaced, a bit longer arrows, etc;
• the two diagonal arrows labeled, being df o X the upper one and Y o f the lower one;
• the label Y in the rightmost arrow be on the right, and not on the left of it.

I browsed the site a bit looking for a similar diagram but I couldn't find anything. I could only get what's in the image and I don't know how to do it. Can someone help me please? Thanks.

You can increase the column sep and row sep; label positions can be swapped from the default placement on the left of the arrow.

You don't need to load amstext (amsmath does it) and amsfonts (amssymb does it).

Also, the {\rm d} syntax has been deprecated for more than twenty years. Using \diff as defined also puts a thin space where appropriate.

\documentclass[a4paper, 12pt]{article}
\usepackage{amsmath, amssymb, amsthm, euscript}
\usepackage{tikz-cd}
\usetikzlibrary{babel}

\newcommand{\diff}{\mathop{}\!\mathrm{d}}

\begin{document}

$\begin{tikzcd}[column sep=4em,row sep=4em] TM \ar[r, "\diff f"] \ar[d, swap, "\pi"] & TN \ar[d, "\pi"] \\ M \ar[ur, shift right = .75ex, swap, "\diff f \circ X"] \ar[ur, shift left = .75ex, "Y \circ f"] \ar[r, "f"] \ar[u, bend left = 50, "X"] & N \ar[u, bend right = 50, swap, "Y"] \end{tikzcd}$

\end{document}


• This is perfect, thanks a lot, and for the extra tips too! Just for curiosity, what does that "swap" do? – Ivo Terek Jul 17 '16 at 19:33
• @IvoTerek With swap you declare that the following label is placed on the right of the arrow (determined like you do with rivers). You can even place two labels, with \arrow[r,"a",swap,"b"]. – egreg Jul 17 '16 at 19:36