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}
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}
9
  • 1
    Yes, exactly what I was looking for, thank you very much!
    – user243350
    Jun 2 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 2 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 2 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 2 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 2 at 11:26
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

2
  • 1
    Thank you very much to have cited me with....."to Sebastiano's great answer".
    – Sebastiano
    Jun 2 at 16:00
  • 1
    Well it does exactly what the OP asked, so it is great :) Jun 2 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.