0

In the output of my diagram in tikzcd, the arrow labels are displaced. I guess the problem is the subscript C_T, but I don't know how to fix this.

1
  • 1
    Welcome! Please add the code that produces this diagram. Most likely the issue can be resolved by using \mathcal{C}_{\vphantom{T}} for the left matrix entry.
    – user194703
    Feb 9, 2020 at 19:13

1 Answer 1

1

Whenever the dimensions of the cells differ, the bent arrows may not be horizontal, and, as a consequence, the edge labels may appear misplaced. There are many ways to fix this, the following code describes two of them.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\[
 \begin{tikzcd}
  \mathcal{C} \arrow[r,bend left,"F_T"] & 
    \mathcal{C}_T \arrow[l,bend left,"G_T"]
 \end{tikzcd}
 \quad\text{vs.}\quad
 \begin{tikzcd}% make the box sizes equal
  {}_{\phantom{T}}\mathcal{C} \arrow[r,bend left,"F_T"] & 
    \mathcal{C}_T \arrow[l,bend left,"G_T"]
 \end{tikzcd}
 \quad\text{vs.}\quad
 \begin{tikzcd}% shift the edge label positions
  \mathcal{C} \arrow[r,bend left,"F_T" {pos=0.6}] & 
    \mathcal{C}_T \arrow[l,bend left,"G_T" {pos=0.4}]
 \end{tikzcd}
\]
\end{document}

enter image description here

The left diagram is the original. In the middle one, a phantom is used to make the sizes of the cells equal. In the right one, the edge labels get shifted.

If you want to fix this once and for all, you can introduce your own style that takes care of this. Then all you need to do is to use hbend left instead of bend left.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{calc}
\tikzset{hbend left/.style={
    to path={let \p1=($(\tikztotarget)-(\tikztostart)$),
        \p2=($(\tikztostart.north)-(\tikztostart.south)$),
        \p3=($(\tikztotarget.north)-(\tikztotarget.south)$),
        \n1={max(\y2,\y3)/2} in
    \ifdim\x1>0pt
     ([yshift=\n1]\tikztostart.east) to[bend left] ([yshift=\n1]\tikztotarget.west)
    \else
     ([yshift=-0.7*\n1]\tikztostart.west) to[bend left] ([yshift=-0.7*\n1]\tikztotarget.east)
    \fi
    }}}
\begin{document}
\[
 \begin{tikzcd}
  \mathcal{C} \arrow[r,hbend left,"F_T"] & 
    \mathcal{C}_T \arrow[l,hbend left,"G_T"]
 \end{tikzcd}
\]
\end{document}

enter image description here

You must log in to answer this question.

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