![如何在 tikz-cd 中标记循环箭头?](https://linux22.com/image/439924/%E5%A6%82%E4%BD%95%E5%9C%A8%20tikz-cd%20%E4%B8%AD%E6%A0%87%E8%AE%B0%E5%BE%AA%E7%8E%AF%E7%AE%AD%E5%A4%B4%EF%BC%9F.png)
如何在 tikz-cd 中为循环箭头添加标签?我想将循环箭头标记为“id”。代码片段:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
M \arrow{r}{\iota_1} \arrow{d}{\iota_2} & G_1 \arrow[shift left=0.8ex]{ld}{g_1} \arrow[loop right]\\
G_2 \arrow{ru}{g_2} \arrow[loop below]
\end{tikzcd}
\end{document}
答案1
尝试
\documentclass[margin=3mm]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
M \ar[r, "\iota_1"] \ar[d, "\iota_2"]
& G_1 \ar[ld, shift left, "g_1"] \ar[loop right, "id"]\\
G_2 \ar[ru, shift left, "g_2"] \ar[loop below, "id"]
\end{tikzcd}
\end{document}
附录: 为了遵循@Sebastian 评论中的建议,这里有一个为了美化上述建议的解决方案而做出的一点点努力的例子:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[sep=large,
every cell/.append style = {inner sep=2pt},
every label/.append style = {inner sep=1pt},
every arrow/.append style = {-{Straight Barb[scale=0.8]}},
]
M \ar[r, "\iota_1"] \ar[d, "\iota_2" ']
& G_1 \ar[ld, shift left=1.5pt, "g_1"] \ar[looseness=4, out=30, in=330, "id"]\\
G_2 \ar[ru, shift left=1.5pt, "g_2"] \ar[looseness=6, out=300, in=240, "id"]
\end{tikzcd}
\end{document}