如何在 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}