4

In making commutative diagrams in tikz-cd I've been wanting to add in 'mapping' arrows that describe what particular elements map to, parallel to the main diagram arrows.

I've been doing it in the following way, which seems fairly clumsy since the 'map' arrows are separated from the main diagram at a large distance, when ideally they would be close by and parallel to the corresponding maps. What would be a better way to do this?

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}
a \arrow[r, maps to] & \phi(a) & \\
R\arrow[r, hook, "\phi"] \arrow[dr, hook, "\iota"] & K & \phi(k) \\
a \arrow[dr, maps to] & Q(R) \arrow[u, dotted, "\exists ! \Phi"'] & \frac{a}{1} \arrow[u, maps to] \\
 & \frac{a}{1} & 
\end{tikzcd}
\end{document}
1
  • (1) welcome, (2) as always on this site please post a full minimal example instead of a sniplet. Then it is a lot easier to help, especially when we don't have to guess.
    – daleif
    Apr 8, 2019 at 15:42

2 Answers 2

3

This is my proposal

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,cd,positioning}
\tikzset{|/.tip={Bar[width=.8ex,round]}} %https://tex.stackexchange.com/a/252544/156344
\begin{document}
\begin{tikzpicture}
\node (r) at (0,0) {$R$};
\node (k) at (3,0) {$K$};
\node (q) at (3,-3) {$Q(R)$};
\node (ra) at (0,.8) {$a$};
\node (ka) at (3,.8) {$\phi(a)$};
\node (kb) at (4,0) {$\phi(k)$};
\node (qb) at (4,-3) {$\frac a1$};
\path (q) node[below left=1em and 1em] (qc) {$\frac a1$};
\path (r) node[below left=1em and 1em] (rc) {$a$};
\draw[right hook->] (r)--(k) node[midway,above] {$\scriptstyle\phi$};
\draw[right hook->] (r)--(q) node[midway,above right] {$\scriptstyle\iota$};
\draw[dotted,->] (q)--(k) node[midway,right] {$\scriptstyle\exists!\Phi$};
\draw[|->] (ra) edge (ka) (qb) edge (kb) (rc) edge (qc);
\end{tikzpicture}
\end{document}

enter image description here

5

You can reduce the spacing, but in my opinion it's clearer and more elegant if you make two diagrams.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}

\begin{document}

\[
\begin{tikzcd}
a \arrow[r, maps to] & \phi(a) &[-2em] \\[-4ex]
R\arrow[r, hook, "\phi"] \arrow[dr, hook, "\iota"] & K & \phi(a) \\
& Q(R) \arrow[u, dotted, "\exists ! \Phi"'] & \frac{a}{1} \arrow[u, maps to] \\[-10ex]
a \arrow[dr, maps to] \\
& \frac{a}{1} & 
\end{tikzcd}
\]

\[
\begin{tikzcd}
R\arrow[r, hook, "\phi"] \arrow[dr, hook, "\iota"] & K &
a \arrow[r, maps to,"\phi"] \arrow[dr, maps to,"\iota"] & \phi(a) \\
& Q(R) \arrow[u, dotted, "\exists ! \Phi"'] &
& \frac{a}{1} \arrow[u, maps to,"\Phi"']
\end{tikzcd}
\]

\end{document}

enter image description here

1
  • I might try playing around with the spacing, thanks Apr 8, 2019 at 15:57

You must log in to answer this question.

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