2

I was drawing a diagram on natural transformation using tikzcd. However, I don't know why the output was "skewed":

\documentclass{article}
\usepackage{mathrsfs}
\usepackage{tikz-cd}
\begin{document}
\[\begin{tikzcd}
\mathscr{O}(X)^{op}
\arrow[r, bend left, "\Lambda A"]
\arrow[r, bend right, swap, "\Lambda A'"]
\arrow[r, phantom, bend left, shift right=0.2ex, ""{name=U}]
\arrow[r, phantom, bend right, shift left=0.2ex, swap, ""{name=D}]
&\textbf{Set}
\arrow[Rightarrow, from=U, to=D, "\Lambda f"]
\end{tikzcd}\]
\end{document}

I got the following skewed output: enter image description here

Now when compared to a similar code:

\documentclass{article}
\usepackage{mathrsfs}
\usepackage{tikz-cd}
\begin{document}
\[\begin{tikzcd}
\mathscr{A}
\arrow[r, bend left, "F"]
\arrow[r, bend right, swap, "G"]
\arrow[r, phantom, bend left, shift right=0.2ex, ""{name=U}]
\arrow[r, phantom, bend right, shift left=0.2ex, swap, ""{name=D}]
&\mathscr{B}
\arrow[Rightarrow, from=U, to=D, "\alpha"]
\end{tikzcd}\]
\end{document}

And it give a beautiful output:

enter image description here

Is there some way to fix this?

3 Answers 3

4

The issue is that the height and width of \mathscr{O}(X)^{op} is different from the height and width of \textbf{Set}.

enter image description here

tikz-cd bends the arrows unequally when those boxes aren't the same size, which affects the positioning of the arrow labels and the placement of U and D.

One way to give \textbf{Set} the exact same box as \mathscr{O}(X)^{op} is to \rlap the \textbf{Set} with an invisible \mathscr{O}(X)^{op} using \phantom.

enter image description here

I added a space before Set because I thought it looked better that way. You can remove or adjust to your liking. Also, instead of using the two phantom arrows, you can name the space above or below the arrow, as I did in the code below. If you want the center arrow to be closer to the curved arrows you can use shorten <= and shorten >= with negative values.

\[\begin{tikzcd}
\mathscr{O}(X)^{op}
\arrow[r, bend left, "\Lambda A", ""{name=U, below}]
\arrow[r, bend right, swap, "\Lambda A'", ""{name=D, above}]
&\rlap{\textbf{\ Set}}\phantom{\mathscr{O}(X)^{op}}
\arrow[Rightarrow, from=U, to=D, "\Lambda f"]
\end{tikzcd}\]
2

With manual tweak of arrows labels positions:

\documentclass{standalone}%article
\usepackage{mathrsfs}
\usepackage{tikz-cd}

\begin{document}
%\[
\begin{tikzcd}
\mathscr{O}(X)^{op}
    \ar[r, bend  left, pos=0.47, "\Lambda A"]
    \ar[r, bend right, pos=0.47, swap, "\Lambda A'"]
    \ar[r, phantom, bend left, ""{name=U}]
    \ar[r, phantom, bend right, pos=0.47, ""{name=D}]
        &   \textbf{Set}
                \ar[Rightarrow, from=U, to=D, "\Lambda f"]
\end{tikzcd}
%\]
\end{document}

enter image description here

2

My proposal using xy package (for the commutative diagrams) with the option 2cell.

\documentclass[12pt]{article}
\usepackage{amssymb}
\usepackage[cmtip,all,2cell]{xy}
\UseTwocells
\usepackage{mathrsfs}
\begin{document}
\[\xymatrix@R=3pc@C=3pc{\mathscr{O}(X)^{op}\rtwocell<7>^{\Lambda A}_{\Lambda A'}{\mkern15mu\Lambda f} &\textbf{Set}}\]
\end{document}

enter image description here

1
  • 1
    +1: You really like the xy package, right? :) Mar 20, 2021 at 0:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .