- 在箭头上可以放置几个鼻子。它们的选项可以设置在箭头上方或下方,或箭头上的任何其他位置,
quotes
您可以在图书馆的帮助下在箭头上书写标签
- 选项
auto
根据箭头方向在箭头上定位标签。请参阅下面的@Qrrbrbirlbel 评论(感谢您指出这一点)
\documentclass[margin=3mm, preview]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, automata,
quotes}
\begin{document}
\begin{tikzpicture}[auto,
node distance = 22mm,
> = Stealth
]
\node[state, initial] (p) {p};
\node[state,accepting, right of=p] (q) {q};
%
\draw[->] (q) edge[loop above] node{a} (q);
\draw[->] (p) edge node[above] {b} node[below] {c} (q);
\end{tikzpicture}
\bigskip
\begin{tikzpicture}[auto,
node distance = 22mm,
> = Stealth
]
\node[state, initial] (p) {p};
\node[state,accepting, right of=p] (q) {q};
\draw[->] (q) edge[loop above, "a"] (q);
\draw[->] (p) edge["b", "c" '] (q); % or "swap" instead of '
\end{tikzpicture}
\end{document}