你好,我想在论文中添加一个有限状态换能器,它看起来像这样
使用 tikz
库。我不明白它是如何工作的。
我正在处理的代码
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{tikz}
\usepackage{graphicx}
\usetikzlibrary{arrows,automata}
\setmainfont[Mapping=tex-text]{Times New Roman}
\newfontfamily{\malayalam}{Meera}
\newfontfamily{\kannada}{Kedage Normal}
\begin{document}
digraph finite_state_machine {
rankdir=LR;
size="8,5"
node [shape = doublecircle, label="{f}", fontsize=12] f;
node [shape = doublecircle, label="{q2, f}", fontsize=10] q2f;
node [shape = circle, label="S", fontsize=14] S;
node [shape = circle, label="{q1}", fontsize=12] q1;
node [shape = circle, label="{q2}", fontsize=12] q2;
node [shape = point ]; qi
qi -> S;
S -> q1 [ label = "a" ];
S -> q2f [ label = "b" ];
S -> q2 [ label = "c" ];
q1 -> q2 [ label = "b" ];
q2f -> f [ label = "b" ];
q2f -> q2 [ label = "c" ];
q2 -> f [ label = "b" ];
q2 -> q2 [ label = "c" ];
}
\end {document}
任何帮助均感激不尽。
答案1
这是用 TikZ 完成的版本。下次,请发布一些与您要做的事情相关的代码!代码似乎与问题无关,这相当令人困惑。
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{automata,positioning,arrows.meta}
\begin{document}
\begin{tikzpicture}
[
initial/.style={line width=1pt},
accepting by double/.append style={line width=1pt},
semithick,
]
\node (0) [state, initial] {$0$};
\node (1) [state, above right=of 0] {$1$};
\node (2) [state, right=of 1] {$2$};
\node (3) [state, right=of 2] {$3$};
\node (5) [state, below right=of 0] {$5$};
\node (6) [state, right=of 5] {$6$};
\node (7) [state, right=of 6] {$7$};
\node (4) [state, below right=of 3, accepting] {$4$};
\path [-{Stealth[]}]
(0) edge node [above, sloped] {$x:x$} (1)
edge node [below, sloped] {$a:a$} (5)
(1) edge node [above] {$a:a$} (2)
(2) edge node [above] {$X:X$} (3)
(3) edge node [above, sloped] {$i:i$} (4)
(5) edge node [below] {$w:w$} (6)
(6) edge node [below] {$r:r$} (7)
(7) edge node [below, sloped] {$a:a$} (4)
(3) edge [dashed] node [above, sloped] {$y:i+a=ya$} (5)
;
\end{tikzpicture}
\end{document}