在交换图中映射箭头

在交换图中映射箭头

在 tikz-cd 中制作交换图时,我一直想添加“映射”箭头来描述特定元素映射到什么,与主图箭头平行。

我一直按照以下方式操作,但这种方式似乎相当笨拙,因为“地图”箭头与主图相距很远,而理想情况下它们应该靠近且与相应的地图平行。有什么更好的方法可以做到这一点?

\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

这是我的建议

\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}

在此处输入图片描述

答案2

您可以减少间距,但我认为如果您制作两个图表会更清晰、更优雅。

\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}

在此处输入图片描述

相关内容