这是一个后续问题Tikz 带节点的子弹半径。
现在所有节点的样式都已更改,边的标签已“受损”。解决这个问题的标准方法是什么?是否可以定义两个节点别名,比如
nodeLb
和nodePt
?
\begin{tikzpicture}[bullet/.style={circle, fill,minimum size=4pt,
inner sep=0pt, outer sep=0pt},nodes=bullet]
\draw (18:1cm) node[label=18:2] (2){} to[out=124,in=-16] node[above right] {c}
(90:1cm) node[label=90:3] (3){} -- node[above right] {e}
(162:1cm) node[label=162:4] (4){} to[out=-52,in=88] node[above right] {g}
(234:1cm) node[label=234:5] (5){} -- node[above right] {h}
(306:1cm) node[label=126:1] (1){} -- node[above right] {b} (2);
\draw (2) to[out=164,in=-56] node[above right] {d} (3);
\draw (4) to[out=-92,in=128] node[above right] {f} (5);
\draw (1) to[out=0,in=-108,looseness=30,loop] node[above right] {a} (1);
\end{tikzpicture}
答案1
发生这种情况的原因是,您说了nodes=bullet
,这会将样式应用于所有节点。当所有节点都应该是项目符号时,这是一个方便的技巧,但在这个扩展示例中,情况不再如此。因此,您可以只向应该是项目符号的节点添加项目符号。此外,我建议对边缘上的节点使用auto
或auto,swap
代替。above right
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle, fill,minimum size=4pt,
inner sep=0pt, outer sep=0pt}]
\draw (18:1cm) node[bullet,label=18:2] (2){} to[out=124,in=-16]
node[auto,swap] {c}
(90:1cm) node[bullet,label=90:3] (3){} -- node[auto,swap] {e}
(162:1cm) node[bullet,label=162:4] (4){} to[out=-52,in=88] node[auto] {g}
(234:1cm) node[bullet,label=234:5] (5){} -- node[auto,swap] {h}
(306:1cm) node[bullet,label=126:1] (1){} -- node[auto,swap] {b} (2);
\draw (2) to[out=164,in=-56] node[auto] {d} (3);
\draw (4) to[out=-92,in=128] node[auto,swap] {f} (5);
\draw (1) to[out=0,in=-108,looseness=30,loop] node[auto] {a} (1);
\end{tikzpicture}
\end{document}