3

I wonder how to draw the typical Functor-Diagram (picture below) in tikz-cd. I know how to draw commutative diagrams, however I don't know how to make the short \mapsto arrows as well as the mapsto arrow in between the vertical arrows. Thanks in advance for any help.

enter image description here

Edit (code that produces errors, namely the ngerman package):

\documentclass{amsart}

%Standardpakete \usepackage{amsmath} \usepackage[ngerman]{babel} \usepackage{tikz-cd}

\begin{document} $$ \begin{tikzcd} \mathsf{C}^{\mathsf{op}} \arrow[rr, "F"] & & \mathsf{D} \ c \arrow[dd, "f"'] & \mapsto & Fc \ & \mapsto & \ c' & \mapsto & Fc' \arrow[uu, "Ff"'] \end{tikzcd} $$ \end{document}

Sebastiano
  • 54,118

2 Answers2

6

Something like this?

\documentclass[a4paper,12pt]{article}
\usepackage{newtxtext,newtxmath}
\usepackage{mathtools}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
\mathsf{C}^{\mathsf{op}} \arrow[rr, "F"] &  & \mathsf{D} \\
c \arrow[dd, "f"'] & \mapsto & Fc  \\
& \mapsto & \\
c' & \mapsto & Fc' \arrow[uu, "Ff"']
\end{tikzcd}
\end{document}

enter image description here

Addendum on request of the user. I think that the problem it is the ngerman babel. You can fix it putting,

\usetikzlibrary{babel}

\documentclass{amsart}

%Standardpakete \usepackage{amsmath} \usepackage[ngerman]{babel} \usepackage{tikz-cd} \usetikzlibrary{babel}

\begin{document} [ \begin{tikzcd} \mathsf{C}^{\mathsf{op}} \arrow[rr, "F"] & & \mathsf{D} \ c \arrow[dd, "f"'] & \mapsto & Fc \ & \mapsto & \ c' & \mapsto & Fc' \arrow[uu, "Ff"'] \end{tikzcd} ] \end{document}

Sebastiano
  • 54,118
  • 1
    Yes, exactly what I was looking for, thank you very much! – user243350 Jun 02 '21 at 11:13
  • 1
    I am using the documentclass amsart and it appears that your code does not work in that class, do you know why or how to fix it? – user243350 Jun 02 '21 at 11:19
  • 1
    @user243350 Here in this community it is necessary to add a minimal working example (a full code of your work). After I have tried with amsart class and the code work correctly. – Sebastiano Jun 02 '21 at 11:21
  • 1
    Ok, I am sorry, I will try to extract the necessary piece of code of my document shortly. Thank you for the advice. – user243350 Jun 02 '21 at 11:22
  • 1
    It appears there is nothing wrong with your code when I extract the necessary packages into a seperate argument, so there has to be some error on my side. I will try to fix it, thank you for your efforts! – user243350 Jun 02 '21 at 11:26
  • I found the error but don't know how to fix it, perhaps you do. I edited the post and copied a sample code that produces the error I get and this is caused by the ngerman package I am using. If you know how to fix it I would be very greatful. I am selftaught in Latex so my knowledge is extremely limited. – user243350 Jun 02 '21 at 11:41
  • 1
    @user243350 The problem it is the language. See my edit where I have added \usetikzlibrary{babel}. Keep in mind that I am not very good at LaTeX. :-)..I remember to not use double $$ ...$$. It is depreciated. – Sebastiano Jun 02 '21 at 11:47
  • 1
    Thank you so much once again, it has fixed the problem. Is there a reason for $$...$$ being depreciated? I think this would produce errors in this case and I use it all the time. Understanding why it is bad would probably help to know when to avoid using it. – user243350 Jun 02 '21 at 11:50
  • 1
    @user243350 See, please, this link https://tex.stackexchange.com/questions/503/why-is-preferable-to – Sebastiano Jun 02 '21 at 11:51
4

As an alternative to Sebastiano's great answer, it is possible to name the arrows f and Ff and add an arrow between them, then shorten the arrow:

\begin{tikzcd}[column sep=large, row sep=tiny]
\mathsf{C}^{\mathsf{op}} \arrow[r, "F"] &  \mathsf{D} \\
c \arrow[d, "f"'{name=f}]\arrow[r,mapsto] & Fc  \\[5ex]
c'\arrow[r,mapsto] & Fc' \arrow[u, "Ff"'{name=Ff}]
\arrow[mapsto,from=f, to=Ff,shorten=0.7em]
\end{tikzcd}

enter image description here

Another option could be add an empty arrow name in the inner part of the diagram and add the arrow as before

\begin{tikzcd}[column sep=large, row sep=tiny]
\mathsf{C}^{\mathsf{op}} \arrow[r, "F"] &  \mathsf{D} \\
c \arrow[d, "f"', ""{name=f}]\arrow[r,mapsto] & Fc  \\[5ex]
c'\arrow[r,mapsto] & Fc' \arrow[u, "Ff"', ""{name=Ff}]
\arrow[mapsto,from=f, to=Ff]
\end{tikzcd}

enter image description here

Luis Turcio
  • 2,757