# Drawing diagrams of higher categories with TikZ

I a planning to give an introductive talk about strict n-categories and I wanted to use TikZ to show the relations between the k-morphims by some cellular diagrams.

To be precise, I want to draw diagrams just like the four diagrams you can find at the top of the page vi of the introduction of Tom Leinster's book "Higher Operads, Higher Categories" http://arxiv.org/abs/math.CT/0305049

The two firsts are of course easy. For the third one I was able to find this

\begin{tikzcd}
A \arrow[bend left=50]{r}[name=U,below]{} \arrow[bend right=50]{r}[name=D]{} & B \arrow[Rightarrow,to path={(U) -- (D)}]{}
\end{tikzcd}


Unfortunatly I have no clue how to modify my code to draw the last one. Any Ideas ?

-
Hope I added the correct picture. Please always add a screen shot of the picture than just giving the link. – Harish Kumar Feb 2 '14 at 0:06
Yes, that's the correct one. Thank you. – Vorph Feb 2 '14 at 0:07

## 3 Answers

Something like this?

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

\begin{document}

\begin{tikzcd}[column sep=3cm]
a
\arrow[bend left=50]{r}[name=U,below]{}{f}
\arrow[bend right=50]{r}[name=D]{}[swap]{g}
&
b
\arrow[Rightarrow,to path={(U) to[out=-150,in=150] node[auto,swap] {$\scriptstyle\alpha$} coordinate (M) (D)}]{}
\arrow[Rightarrow,to path={(U) to[out=-30,in=30] node[auto] {$\scriptstyle\beta$} coordinate (N)  (D)}]{}
\arrow[Rightarrow,to path={([xshift=4pt]M) -- node[auto] {$\scriptstyle\Gamma$} ([xshift=-4pt]N)}]{}
\end{tikzcd}

\end{document}


With a little more work the original style can be emulated:

\documentclass{article}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{tikz-cd}
\usetikzlibrary{calc,arrows}

\tikzset{
mydot/.style={circle,fill,inner sep=1.5pt},
commutative diagrams/.cd,
arrow style=tikz,
diagrams={>=latex},
}

\begin{document}

\begin{tikzcd}[column sep=3cm]
\arrow[to path={node[mydot,label={left:$a$}] {}}]{}
\arrow[bend left=50]{r}[name=U,below]{}{f}
\arrow[bend right=50,shorten >= -3.5pt,shorten <= -3.5pt]{r}[name=D]{}{}
\arrow[to path={node[below,yshift=-2pt] at (D) {$\scriptstyle g$} {}}]{}
&
\arrow[to path={node[mydot,label={right:$b$}] {}}]{}
\arrow[Rightarrow,to path={(U) to[out=-160,in=160] node[auto,swap] {$\scriptstyle\alpha$} coordinate (M) (D)}]{}
\arrow[Rightarrow,to path={(U) to[out=-20,in=20] node[auto] {$\scriptstyle\beta$} coordinate (N)  (D)}]{}
\arrow[to path={node[label={center:\scalebox{1.9}[0.75]{$\Rrightarrow$}},label={[yshift=-2pt]above:$\scriptstyle\Gamma$}] at ( $(M)!0.5!(N)$ ) {}}]{}
\end{tikzcd}

\end{document}


-
Seems great ! Thank you ! – Vorph Feb 2 '14 at 0:14
@Vorph I updated my answer with a new version resembling the original settings a little more. – Gonzalo Medina Feb 2 '14 at 3:12
Just saw it. I was wondering how to do a "triple arrow", so thanks again. – Vorph Feb 2 '14 at 9:31
@Vorph You're welcome! I see that you've up-voted answers. Thanks! Don't forget that you can also accept the answer you consider best solved your problems (up-vote and accepting are two different actions). In case of doubt, please see How do you accept an answer?. – Gonzalo Medina Feb 2 '14 at 15:49

Here a solution with only tikz :

\documentclass[11pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{tikz}
\usetikzlibrary{arrows,calc}

\begin{document}

\begin{tikzpicture}[>=latex,
every node/.style={auto},
arrowstyle/.style={double,->,shorten <=3pt,shorten >=3pt},
mydot/.style={circle,fill}]

\coordinate[mydot,label=left:$a$](a)  at (0,0);
\coordinate[mydot,label=right:$b$](b) at (3,0);

\draw[->]   (a) to[bend left=50]  coordinate (f) node[]{$f$}          (b);
\draw[->]   (a) to[bend right=50] coordinate (g) node[,swap] {$g$}    (b);

\draw[arrowstyle] (f) to node[right]{$\alpha$} (g);

\coordinate[mydot,label=left:$a$](a)  at (6,0);
\coordinate[mydot,label=right:$b$](b) at (11,0);

\draw[->]         (a) to[bend left=50]  coordinate (f) node[]{$f$}          (b);
\draw[->]         (a) to[bend right=50] coordinate (g) node[,swap] {$g$}    (b);

\draw[arrowstyle] (f) to[bend left=50]       node (p){$\beta$}  (g);
\draw[arrowstyle] (f) to[bend right=50,swap] node (q){$\alpha$} (g);

\draw[arrowstyle] (q.east) to node[above]{$\Gamma$} (p.west);
\end{tikzpicture}

\end{document}


-
We missed you Alain! :) – percusse Feb 2 '14 at 9:26
@percusse Thanks! I'll try to come more regularly – Alain Matthes Feb 2 '14 at 14:04
@AlainMatthes I agree with percusse. Good to have you back, Alain! – Gonzalo Medina Feb 2 '14 at 16:04

Here's a solution using Metapost. I could not find any examples on the web for doing double and triple lines, so I've just made up an approach using different pen widths and undraw. I've stuck to standard MP arrowheads, but with a little extra work we could change to open, curly arrows as needed.

prologues := 3;
outputtemplate := "%j%c.eps";

vardef double_line_arrow(expr p) =
interim linecap:=butt;
draw p cutafter fullcircle scaled ahlength
shifted point length(p) of p withpen currentpen scaled 3;
undraw p;
filldraw arrowhead p;
enddef;

vardef triple_line_arrow(expr p) =
interim linecap := butt;
draw   p cutafter fullcircle scaled (1.5*ahlength)
shifted point length(p) of p withpen currentpen scaled 5;
undraw p withpen currentpen scaled 3;
drawarrow p;
enddef;

beginfig(1);
dotlabel.bot(btex $a$ etex,origin);
endfig;

beginfig(2);
z1 = origin; z2 = right scaled 2cm;
path ab; ab = z1--z2;
drawarrow ab cutafter fullcircle scaled 3 shifted z2;
% stop arrow slightly short of the dotlabel
dotlabel.llft(btex $a$ etex,z1);
dotlabel.lrt (btex $b$ etex,z2);
label.top(btex $f$ etex, point .5 of ab);
endfig;

beginfig(3);
z1 = origin;
z2 = right scaled 2cm;

path ab[];
ab1 = z1{dir 60} .. {dir -60}z2; ab2 = ab1 reflectedabout(origin,right);
drawarrow ab1 cutafter fullcircle scaled 3 shifted z2;
drawarrow ab2 cutafter fullcircle scaled 3 shifted z2;
dotlabel.llft(btex $a$ etex,z1);
dotlabel.lrt (btex $b$ etex,z2);

z3 = point .5 of ab1;
z4 = point .5 of ab2;
label.top(btex $f$ etex,z3);
label.bot(btex $g$ etex,z4);

path fg;
fg =  z3 -- z4 cutbefore fullcircle scaled 8pt shifted z3
cutafter  fullcircle scaled 8pt shifted z4;
double_line_arrow(fg);
label.rt(btex $\alpha$ etex, point .5 of fg);
endfig;

beginfig(4);
z1 = origin;
z2 = right scaled 2.2cm;

path ab[]; ab1 = z1{dir 60} .. {dir -60}z2; ab2 = ab1 reflectedabout(origin,right);
drawarrow ab1 cutafter fullcircle scaled 3 shifted z2;;
drawarrow ab2 cutafter fullcircle scaled 3 shifted z2;;
dotlabel.llft(btex $a$ etex,z1);
dotlabel.lrt (btex $b$ etex,z2);

z3 = point .5 of ab1;
z4 = point .5 of ab2;
label.top(btex $f$ etex,z3);
label.bot(btex $g$ etex,z4);

path fg[];
fg1 =  z3{dir -150} .. {dir -30} z4
cutbefore fullcircle scaled 8pt shifted z3
cutafter  fullcircle scaled 8pt shifted z4;
fg2 =  fg1 reflectedabout(z3,z4);

z5 = point .5 of fg1;
z6 = point .5 of fg2;

double_line_arrow(fg1); label.lft(btex $\alpha$ etex, z5);
double_line_arrow(fg2); label.rt (btex $\beta$  etex, z6);

ab3 = z5 -- z6
cutbefore fullcircle scaled 4pt shifted z5
cutafter  fullcircle scaled 4pt shifted z6;
triple_line_arrow(ab3);
label.top(btex $\Gamma$ etex, point .5 of ab3);
endfig;
end.


The figures 1..4 are included in this picture from left to right.

-