[Tex/LaTex] Mapping arrows in commutative diagrams

commutative-diagramstikz-cd

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}

Best Answer

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

Related Question