TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make a diagram similar to this (from wikipedia)

Kan extension diagram

Except that I want to the double arrow $\eta$ two be pointing from node $B$ toward the middle of arrow $X$ (it is, after all, a natural transformation from $RF$ to $X$).

I'm trying to use the \xtwocell command of the 2cell package for xy. In subsection 3 (Excursions) of section 25.4 (extra options) of chapter 25 (two-cell) on page 47 of the xyrefer manual, it is stated

\xtwocell[⟨hop⟩]{⟨displace⟩}... connects to the ⟨pos⟩ displaced by ⟨displace⟩ from the relative cell location specified by ⟨hop⟩. The displacement can be any string of valid XY-pic commands, but they must be enclosed within a group {...}. When the cell location is the target, a null grouping {} must be given. When used with the <\omit> nudge, such excursions allow a labelled Arrow to be placed anywhere within an XY-pic diagram; furthermore the Arrow can be oriented to point in any direction.

Of course the manual gives no examples and makes no further comment about how to change the orientation of the Arrow (in this manual, capitalized "Arrow" refers to the double arrow between arrows, i.e. the 2-cell).

What does he mean by "any string of valid XY-pic commands"? What may the displacement argument for \xtwocell be? Any experiments I tried (eg <1>,dr,[0,1]) typing in the curly braces just ended up in the $A$ node text, so not being interpreted as a displacement or position or orientation. How do I change the orientation of the Arrow? How do I achieve the "orientation in any direction" that was promised me?

Here is my simple markup

A\ar[d]\ar[r]\xtwocell[0,1]{}\omit{<2>} & B\\
C\ar@{.>}[ur] &

which gives the following image

bad diagram

I want to change the direction that double arrow is pointing, point it to the corner object $C$, or reverse it. I can shift it by changing the number in \omit{<2>}, but how to change the orientation?

(Google showed me that the same question is asked here on the xy mailing list, but never answered)

See also my question at Label the source/target object in the middle of compositemaps from 2cell package of xy? for another attempted method at this diagram.

share|improve this question
I empathize with you, the entry for the two-cell feature in the xyrefer manual is really poor... – lentic catachresis Jun 1 at 10:45

If you would consider using tikz-cd, this can easily be achieved with

  • a named node (name=X) and
  • the to node styles (see below).

The argument of \arrow that usually denotes the direction/target node will be ignored.

For a shorter arrow I’d use the short style from my answer to your other question Label the source/target object in the middle of compositemaps from 2cell package of xy?

You can use the keys short shift >, short shift < and short center to adjust the arrow.

Code A

  /tikz/commutative diagrams/to node/.style={%
    /tikz/execute at begin to=\edef\tikztotarget{#1}},
  /tikz/commutative diagrams/to node*/.style={
    /tikz/commutative diagrams/to node={#1},
    /tikz/shorten >=\pgfkeysvalueof{/tikz/commutative diagrams/to node shorten >}},
  /tikz/commutative diagrams/to node shorten >/.initial=+.5ex}
\begin{tikzcd}[column sep=large]
 A \rar[][name=X]{X}
   & B \\
 C \urar[dashed][swap]{R}
   \arrow[Rightarrow, to node*=X]{}{\eta}

Output A

enter image description here

Code B

\newcommand*{\tikzcdset}{\pgfqkeys{/tikz/commutative diagrams}}
  to node/.style={%
    /tikz/execute at begin to=\edef\tikztotarget{#1}}}
  short shift >/.initial=+.6em,
  short shift </.initial=+.6em,
  short center/.initial=.5,
    to path={
          \path (\tikztostart) coordinate (@aux1) -- (\tikztotarget) coordinate (@aux2);
        \edef\pgfpathlength{\pgfmathresult pt}%
            {(\pgfkeysvalueof{/tikz/commutative diagrams/short center})*\pgfpathlength-\pgfkeysvalueof{/tikz/commutative diagrams/short shift <}}
            {(\pgfkeysvalueof{/tikz/commutative diagrams/short center})*\pgfpathlength+\pgfkeysvalueof{/tikz/commutative diagrams/short shift >}}
        (@@aux1) -- (@@aux2) \tikztonodes}}
\begin{tikzcd}[column sep=large]
 A \rar[][name=X]{X}
   & B \\
 C \urar[dashed][swap]{R}
   \arrow[Rightarrow, to node=X, short]{}{\eta}

Output B

enter image description here

share|improve this answer
Yes, I would consider using this package. Is it possible to make the double arrow shorter? Seeing a 2cell span the diagram like that is a little jarring. – ziggurism Aug 22 '13 at 5:48
@JoeHannon Could you elaborate on that? You can shorten the arrow at both ends with the keys shorten > and shorten < as shown in the example. There are also ways to shorten the line by a certain percentage of the path length in various different ways. It is also possible to place a normalsized \Rightarrow between C and X similar to the small arrow in your linked question. Feel free to edit your question with a mock-up of the image you want to achieve. – Qrrbrbirlbel Aug 22 '13 at 6:32
In your diagram, it seems like the doublearrow spans from the lower-left corner to your invisible node. But typically we want 2cells to be shorter, hovering somewhere in the center of our commutative diagram. Sorry I can't be more specific, but I can say that the 2-cells displayed by the 2cell package are the right size (not surprising since 2cell was invented by a cat theorist for his book). If I can get a 2-cell of the size given by 2cell, but with the direction given by your tikz-cd example, then I will be happy. I did not understand your instructions about the shorten > keys, though. – ziggurism Aug 22 '13 at 6:59
@JoeHannon I am not familiar with commutative diagrams or their vocabulary. Do you want something like this? – Qrrbrbirlbel Aug 22 '13 at 8:46
Yes, that arrow does look shorter, and does not span the diagram. – ziggurism Aug 22 '13 at 19:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.