How do I create pasting diagrams in TikZ?

I've been toying with the idea of switching over from Xy-pic to TikZ for all of my diagramming needs, but one feature that's very important to me is the ability to create 2-categorical pasting diagrams (like the ones in Wikipedia's entry on 2-categories), as I can with Xy-pic's "twocell" commands (which, incidentally, I find to be a huge pain to deal with). How do I do these in TikZ? I'd be happy with just a reference to the relevant commands or an arXiv paper with good examples.

-
It's worth pointing out that the linked page "pasting diagrams" doesn't render as intended without MathML support, so it's hard for people to see exactly what you're after here. –  Scott Morrison Jul 26 '10 at 20:28
Thanks Scott, I hadn't thought of that. I'll change the reference. –  Evan Jenkins Jul 26 '10 at 21:25

Making pasting diagrams in TikZ is pretty easy, as has been said; I think easier than in xypic for complicated ones, since it's easy to place the 2-cell arrows exactly where you want them and in exactly the right orientation. One useful trick for placing them is barycentric coordinates; then once you've got a node/coordinate at the center of the 2-cell arrow, you can use adjustments like +(0,0.2) to get to the starting and ending points.

A significant problem, however, is that as far as I know, in versions of TikZ prior to the current CVS version, there is no good way to draw a double-shafted arrow, as is used for 2-cells in pasting diagrams. In the CVS version of TikZ, you can say \draw[double,-implies], but this won't compile for anyone (such as arXiv or a journal editor) who has an older, "released" version of TikZ. For that reason, I'm personally holding off on switching from xypic to TikZ for pasting diagrams until the next version of TikZ is released and becomes at least somewhat more widely available.

-
What's the problem with the double-shafted arrows in older TikZ? Certainly, the "double" option is there. –  Andrew Stacey Aug 13 '10 at 7:19
The "double" option is there but with arrow tips it looks very ugly (IMHO). It works by drawing one very thick black line and then one thinner white line inside it, which produces the appearance of a double-shafted arrow. But when "->" is also given, the very thick line comes with a very thick arrow head, and nothing is done to change that, so it looks mismatched. –  Mike Shulman Sep 18 '10 at 7:13

For such a pasting diagram as on 2-categories, you could use bent arrows and midway coordinates for positioning. I recommend

• Define styles for as many elements as possibly, so easy to use
• Define macros for repeatedly used actions

Here's an example where I do that. Here, it's finally as easy as \connect{node1}{node2}:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\newcommand{\connect}[2]{%
\draw[-angle 60] (#1) to [above] coordinate[midway] (#1#2+) (#2) ;
\draw[-angle 60] (#1) to [below] coordinate[midway] (#1#2-) (#2);
\draw (#1) to coordinate[midway] (#1#2=) (#2);
\draw[double shafted] (#1#2+) -- (#1#2=);
\draw[double shafted] (#1#2-) -- (#1#2=);
}

\begin{document}
\begin{tikzpicture}[%
every node/.style={circle,inner sep=2pt,fill},
node distance=5em,
above/.style={bend left=70,looseness=2},
below/.style={bend right=70,looseness=2},
double shafted/.style={-implies,double,double equal sign distance,
shorten >=2pt, shorten <=3pt}]
\node (a) {};
\node[right of =  a] (b) {};
\node[right of =  b] (c) {};
\connect{a}{b}
\connect{b}{c}
\end{tikzpicture}
\end{document}


-
Would commutative diagrams work equivalently well? If so, see this and this. The TikZ matrix "environment" is a good place to look also.