如何更改 tikzcd 中标签和箭头之间的距离?

如何更改 tikzcd 中标签和箭头之间的距离?

我正在使用 tikzcd 制作一个相当复杂的图表,并希望将箭头上的标签更靠近与其关联的箭头,以消除歧义。这是我目前拥有的:

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\[
\begin{tikzcd}[ampersand replacement = \&, column sep = tiny]
\&  z_1 \ar[r, phantom, description, "\in"]
\&  C   \ar[dd, dashed, "\psi"]
\&  z_2 \ar[l, phantom, description, "\ni"] \\
x_1 \ar[ur, mapsto] \ar[dr, mapsto] \ar[r, phantom, description, "\in"]
\&  G_1 \ar[ur, near start, "\eta_1"]   \ar[dr, near start, "\psi_1"']
\&
\&  G_2 \ar[ul, near start, "\eta_2"']  \ar[dl, near start, "\psi_2"]
\&  x_2 \ar[l, phantom, description, "\ni"] \ar[ul, mapsto] \ar[dl, mapsto] \\
\&  y_1 \ar[r, phantom, description, "\in"]
\&  H
\&  y_2 \ar[l, phantom, description, "\ni"]
\end{tikzcd}
\]
\end{document}

产生

交换图结果

如果我将所有标记的箭头更改为有选项near start,我会得到

具有接近起始结果的交换图

这两个选项似乎都相当模糊,因为地图与哪些标签相关联并不十分清楚。我尝试将inner sep两者都用作全局选项和箭头选项,但似乎没有任何作用。所以我的问题是:

如何使标签更接近它们对应的箭头?

答案1

您可以为标签添加底片outer sep。在下面的代码中,我添加了样式以节省一些输入。

\documentclass{article}
\usepackage{tikz-cd}
\tikzset{close/.style={near start,outer sep=-2pt}}
\begin{document}
\[
\begin{tikzcd}[ampersand replacement = \&, column sep = tiny]
\&  z_1 \ar[r, phantom, description, "\in"]
\&  C   \ar[dd, dashed, "\psi"]
\&  z_2 \ar[l, phantom, description, "\ni"] \\
x_1 \ar[ur, mapsto] \ar[dr, mapsto] \ar[r, phantom, description, "\in"]
\&  G_1 \ar[ur, close, "\eta_1"]   \ar[dr,close, "\psi_1"']
\&
\&  G_2 \ar[ul, close, "\eta_2"']  \ar[dl,close, "\psi_2"]
\&  x_2 \ar[l, phantom, description, "\ni"] \ar[ul, mapsto] \ar[dl, mapsto] \\
\&  y_1 \ar[r, phantom, description, "\in"]
\&  H
\&  y_2 \ar[l, phantom, description, "\ni"]
\end{tikzcd}
\]
\end{document}

代码输出

相关内容