[Tex/LaTex] Adjunction symbol in commutative diagram

math-modesymbolstikz-cd

I'm writing about Category theory using tikz-cd and have a pair of adjoint functors, which is usually denoted by

$F\dashv G$

I would like to have this \dashv symbol in a commutative diagram like this (so it should replace the double arrow).

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\[\begin{tikzcd}[ampersand replacement=\&] C\ar[r,bend left,"F",""{name=A, below}] \& D\ar[l,bend left,"G",""{name=B,below}] \ar[from=A, to=B, Rightarrow]\end{tikzcd}\]
\end{document}

But I don't know how to do this. Could anyone please help me?

Best Answer

You can define your own arrow style which takes a symbol instead of an actual arrow. The rest stays as you have just done.

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\tikzset{%
    symbol/.style={%
        draw=none,
        every to/.append style={%
            edge node={node [sloped, allow upside down, auto=false]{$#1$}}}
    }
}

\begin{document}
$F\dashv G$ or:     
\[
\begin{tikzcd}
C\ar[r,bend left,"F",""{name=A, below}] & D\ar[l,bend left,"G",""{name=B,above}] \ar[from=A, to=B, symbol=\dashv]
\end{tikzcd}
\]
\end{document}

enter image description here


In order to explain this a bit, I made another example:

\documentclass{article}
\usepackage{tikz-cd}
\tikzset{%
    symbol/.style={%
        ,draw=none
        ,every to/.append style={%
            ,edge node={%
                node [%
                    ,sloped
                    ,allow upside down
                    ,auto=false
                    ]{$#1$}
                }
            }
        }
    }

\begin{document}    
\begin{tikzcd}
    \bullet\arrow[symbol={y}]{r}\arrow[symbol={y}]{d}\arrow[symbol={y}]{dr} & \bullet \\
    \bullet & \bullet\arrow[symbol={y}]{l}\arrow[symbol={y}]{u}
\end{tikzcd}
\end{document}

In this code you can just comment out line by line (the single line options in the \tikzset) and easily see what happens. draw=none, sloped, and allow upside down shout be clear than. auto=false is default but I included it in case you use that style inside diagrams where auto is set to true. If you remove this line, nothing will happen in this very case here, but if you just remove =false, you will get a wrong result. Please refer to the manual of tikz-cd in order to get more reference on all those options.

Finally let's have a look on the syntax: I have defined a new TikZ-style for you, which you can use anywhere you want. As we are using this style inside an arrow node, we have to tell it not to draw this very node. Then we say that for any to directive (the arrows in tikz-cd do use that), we want to append the style of an edge node (a node which combines two elements from from to to (see the TikZ) manual). Such an edge node also has a node which is referred to as a label in tikz-cd. It is set on top of the center of that edge node. We define any desired styling for this node (you may insert colors or whatever as well) but leave the actual node text which comes in between the {<some text>} free or better, replace it by {$#1$}. For sure you have seen such dummies for other commands already. It just says that the first argument of this macro shall be inserted in place of the #1 which happens to be in math-mode and inside the node text here. The arguments of TikZ styles are used as a key value directive so now you can use symbol={=}, symbol={\infty} or whatever you like.

Related Question