我正在尝试使用 TikZ 在 LaTeX 中绘制自动机,但我不知道如何在两个状态之间进行长时间过渡。我需要在其上放置一个尺寸标签。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial] (s_0) {Start 1};
\node[state] (s_1) [right=of s_0] {Start 2};
\node[state] (s_2) [right=of s_1] {Start 3};
\path[->]
(s_0) edge [bend left] node {Path not long enough for text} (s_1);
\end{tikzpicture}
\end{document}
得出以下结果:
这里有谁能帮助我吗?
答案1
选择您的选项。
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial] (s_0) {Start 1};
\node[state] (s_1) [right=of s_0] {Start 2};
\node[state] (s_2) [right=of s_1] {Start 3};
\path[->] (s_0) edge [bend left] node[text width=1.5cm,
align=center
] {Path not long enough for text} (s_1);
\end{tikzpicture}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial] (s_0) {Start 1};
\node[state] (s_1) [right=4cm of s_0] {Start 2};% or [node distance=4cm, right=of s_0]
\node[state] (s_2) [right=of s_1] {Start 3};
\path[->] (s_0) edge [bend left] node {Path not long enough for text} (s_1);
\end{tikzpicture}
\end{document}