# Change the orientation of Arrow of xtwocell in the 2cell option for xy

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

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

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


which gives the following image

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.

• I empathize with you, the entry for the two-cell feature in the xyrefer manual is really poor... Jun 1, 2016 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

\documentclass[tikz,convert=false]{standalone}
\usepackage{tikz-cd}
\pgfkeys{
/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{document}
\begin{tikzcd}[column sep=large]
A \rar[][name=X]{X}
\dar[swap]{F}
& B \\
C \urar[dashed][swap]{R}
\arrow[Rightarrow, to node*=X]{}{\eta}
\end{tikzcd}
\end{document}


## Code B

\documentclass[tikz,convert]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{tikz-cd}
\newcommand*{\tikzcdset}{\pgfqkeys{/tikz/commutative diagrams}}
\tikzcdset{
to node/.style={%
/tikz/execute at begin to=\edef\tikztotarget{#1}}}
\makeatletter
\tikzcdset{
short shift >/.initial=+.6em,
short shift </.initial=+.6em,
short center/.initial=.5,
short/.style={
to path={
\pgfextra
\pgfinterruptpath
\path (\tikztostart) coordinate (@aux1) -- (\tikztotarget) coordinate (@aux2);
\endpgfinterruptpath
\pgfpointdiff{\pgfpointanchor{@aux1}{center}}{\pgfpointanchor{@aux2}{center}}%
\pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
\edef\pgfpathlength{\pgfmathresult pt}%
\pgfcoordinate
{@@aux1}
{\pgfpointlineatdistance
{(\pgfkeysvalueof{/tikz/commutative diagrams/short center})*\pgfpathlength-\pgfkeysvalueof{/tikz/commutative diagrams/short shift <}}
{\pgfpointanchor{@aux1}{center}}
{\pgfpointanchor{@aux2}{center}}}%
\pgfcoordinate
{@@aux2}
{\pgfpointlineatdistance
{(\pgfkeysvalueof{/tikz/commutative diagrams/short center})*\pgfpathlength+\pgfkeysvalueof{/tikz/commutative diagrams/short shift >}}
{\pgfpointanchor{@aux1}{center}}
{\pgfpointanchor{@aux2}{center}}}%
\endpgfextra
(@@aux1) -- (@@aux2) \tikztonodes}}
}
\makeatother
\begin{document}
\begin{tikzcd}[column sep=large]
A \rar[][name=X]{X}
\dar[swap]{F}
& B \\
C \urar[dashed][swap]{R}
\arrow[Rightarrow, to node=X, short]{}{\eta}
\end{tikzcd}
\end{document}


## Output B

• 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. Aug 22, 2013 at 5:48
• @ziggurism 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. Aug 22, 2013 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. Aug 22, 2013 at 6:59
• @ziggurism I am not familiar with commutative diagrams or their vocabulary. Do you want something like this? Aug 22, 2013 at 8:46
• Yes, that arrow does look shorter, and does not span the diagram. Aug 22, 2013 at 19:54

This is the solution that I would use in xypic, I believe that the command you are looking for is to write ^ before the name of the 2-cell, and also before the <2> that moves it to the right. So this will give you the same image:

0.

$\xymatrix@!0@=18mm{ A\ar[d]\ar[r]\xtwocell[d]{}<>{^<-2>a} & B\\ C\ar@{.>}[ur] & }$


Now to get the "correct" direction, is not so easy with xypic, you might have to add more (empty) rows and columns, so you have where to point at. Here are two failed attempts adding an extra row and an extra column. And a succesfull attempt adding two extra rows and two extra columns more.

1.

$\xymatrix@!0@=9mm{ A\ar[dd]\ar[rr] \xtwocell[rd]{}<>{^a}&& B\\ &&\\ C\ar@{.>}[uurr] && }$


2.

$\xymatrix@!0@=9mm{ A\ar[dd]\ar[rr] \xtwocell[rrd]{}<>{^a}&& B\\ &&\\ C\ar@{.>}[uurr] && }$


3.

$\xymatrix@!0@=4.5mm{ A\ar[dddd]\ar[rrrr] &&&& B\\ \xtwocell[rrd]{}<>{^<-1>a}&&&&\\ &&&&\\ &&&&\\ C\ar@{.>}[uuuurrrr] &&&& }$


And this is how they look in order.

There are more ways to draw triangles in xypic, here I leave some examples that I use. Hope they are useful.

$\vcenter{\hbox{\xymatrix@!0@=18mm{ A\ar[r]\ar@{.>}[rd]\xtwocell[rd]{}<>{<-3>a}&C\ar[d]\\ &B\\ }}}\qquad\vcenter{\hbox{\xymatrix@!0@C=15mm{ A\ar[rd]\ar@{.>}[rr]\xtwocell[rr]{}<>{^<2>a}&&B\\&C\ar[ru]& }}}\qquad\vcenter{\hbox{\xymatrix@!0@=18mm{ C\ar[d]&A\ar[l]\ar@{.>}[ld]\xtwocell[ld]{}<>{<3>a}\\ B& }}}$


And how they look,