# Best way to draw complicated 2-cell diagrams

I'm drawing some diagramas and I want to write down some 2-cells. I'm not sure of how to write them down in a good way. This is what I have done with xy:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[spanish,shorthands=off]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[all]{xy}

\begin{document}

\begin{displaymath}
\begin{xy}
(0,0) *+{\mathcal{E}} = "e1",
(15,0) *+{\mathcal{E}} = "e2",
(30,0) *+{\mathcal{S}} = "s1",
(7.5,-10) *+{\mathcal{F}} = "f1",
(40,10) *+{\mathcal{E}} = "e3",
(70,0) *+{\mathcal{S}} = "s2",
(50,15) *+{\mathcal{F}} = "f2",
(65,10) *+{\mathcal{E}} = "e4",
(80,20) *+{\mathcal{F}} = "f3",
\POS "e1" \ar^{1_{\mathcal{E}}} "e2",
\POS "e1" \ar_{g^*} "f1",
\POS "f1" \ar_{g_*} "e2",
\POS "e2" \ar^{p_*} "s1",
\POS "f1" \ar@/_/_{f_*} "s1",
\POS "s1" \ar^{p^!} "e3",
\POS "e3" \ar_{p_*} "s2",
\POS "s1" \ar@/_/_{1_{\mathcal{S}}} "s2",
\POS "e3" \ar^{g^*} "f2",
\POS "f2" \ar^{g_*} "e4",
\POS "e4" \ar_{p_*} "s2",
\POS "f2" \ar@/^25pt/^{f_*} "s2",
\POS "f2" \ar@/^/^{1_{\mathcal{F}}} "f3",
\POS "s2" \ar@/_/_{f^!} "f3",
\POS "e2" \ar@/^10pt/^{1_{\mathcal{E}}} "e3",
%names of natural transformations
\POS (7.5,-2) \ar@{=>}_{\nu} (7.5,-6),
\POS (42,6) \ar@{=>}_{\varepsilon} (45,1),
\POS (57,11) \ar@{=>}_{(p_*\nu)^{-1}} (55,7),
\POS (73,16) \ar@{=>}^{\overline{\eta}} (73,10),
\POS (27,6) \ar@{=>}_{\eta} (29,2),
\end{xy}
\end{displaymath}

\end{document}


which gives the following diagram

As you can see I have drawn the 2-cell "manually". So I would like to know if there is a better way to draw "complicated" diagrams in xy or if is better to use something like tikz-cd.

• Welcome to TeX SX! What exactly do you call a 2-cell? – Bernard Oct 9 '17 at 21:49
• Well, you could probably avoid hard-coding the coordinate values in TikZ and use names etc. But I don't know whether that would be better or not. It probably depends on how many you have to do and how similar they are, among other things. I don't know - can tikz-cd draw stuff like this? – cfr Oct 10 '17 at 3:19
• Thanks @Bernard!!. I think a 2-cell is a natural transformation, normally they are depicted with double line arrows, and they are the main problem in my attempt to draw diagrams. – Luis Turcio Oct 10 '17 at 20:07

I don't really know what a 2-cell diagram is, but it's not terribly difficult to make something like that with tikz-cd. It does use a matrix to position nodes, but that isn't a problem for your diagram.

Most of the double line arrows are drawn between named nodes/edge labels. The only exception is the vertical one in the top right. It is placed relative to the edge label to its left (the one withf_{*}), using the syntax from the calc library.

\documentclass[border=5mm]{standalone}
\usepackage{tikz-cd}
\usepackage{amssymb}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzcd}[
execute at end picture={
\draw [/tikz/commutative diagrams/double line,-Implies] ($(f1)+(5mm,5mm)$) --node[right]{$\bar{\eta}$} ($(f1)+(5mm,-5mm)$);
}
]
&&&&&&&[-5mm]&[-5mm]
\mathcal{F} \\[-15pt]
% second row
&&&&&
\mathcal{E}
\arrow[rrru,bend left=5,"1_{\mathcal{F}}"]
\arrow[rd,"g_{*}"name=g1]
\arrow[rrdd,bend left=45,"f_{*}"name=f1]
&&&  \\
%third row
&&&&
|[alias=e1]|\mathcal{E}
\arrow[ur,"g^{*}"]
\arrow[drrr,"p_{*}"{swap,name=p1}]
&&
\mathcal{E}
\arrow[dr,"p_{*}"swap]
&&  \\
% fourth row
\mathcal{E}
\arrow[rr,"1_{\mathcal{E}}"name=1e]
\arrow[dr,"g_{*}"swap]
&&
\mathcal{E}
\arrow[rru,bend left=15,"1_{\mathcal{E}}"name=1e2]
\arrow[r,"p_{*}"]
&
|[alias=s1]|\mathcal{S}
\arrow[ur,"p^{!}"]
\arrow[rrrr,bend right=5,"1_{\mathcal{S}}"name=1s]
&&&&
\mathcal{S}
\arrow[ruuu,bend right=10,"f_1"swap]
&  \\
% fifth row
&
|[alias=f2]|\mathcal{F}
\arrow[ur,"g_{*}"swap]
\arrow[urr,bend right=15,"f_{*}"swap]
&&&&&&&
% other arrows
\arrow[Rightarrow,from=g1, to=p1,shorten >=3mm,shorten <=3mm,"(p_{*}\nu)^{-1}"swap]
\arrow[Rightarrow,from=1e, to=f2,shorten >=1mm,shorten <=2mm,"\nu"swap]
\arrow[Rightarrow,from=1e2, to=s1,shorten >=0mm,shorten <=2mm,"\eta"swap]
\arrow[Rightarrow,from=e1, to=1s,shorten >=1mm,shorten <=2mm,"\eta"swap]
\end{tikzcd}
\end{document}

• Thanks @Torbjørn is also a large code, but at least is easier to modify to draw similar diagrams (something I have to do), and so much easier to draw natural transformations! – Luis Turcio Oct 10 '17 at 20:17