我对乳胶真的很陌生(使用了约 3 天),我正在尝试为正在解决的问题绘制一个自动机...由于某种原因,我收到了一个错误,我的状态似乎全部都搞乱了。请注意,这样做的目的不是让你帮我做作业。我的解决方案无论如何都是错误的……我只是想看看我是否能正确地绘制状态。任何帮助都将不胜感激。
\documentclass[12pt]{article}
\usepackage{latexsym}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\topmargin = 0.1in \textwidth=5.7in \textheight=8.6in
\oddsidemargin = 0.2in \evensidemargin = 0.2in
\begin{document}
\begin{center}
Theory of Computation, SPRING 2015 \\
Homework Problems\\
\end{center}
\smallskip
\begin{enumerate}
\item L has all strings w such that w does not contain 101
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial, accepting] (q_0) {$q_0$};
\node[state](q_1) [below right=of q_1] {$q_1$};
\path[->]
(q_0)
edge node {0} (q_1)
edge [loop above] node {1} ()
(q_1)
edge [loop above] node {0} ();
\end{tikzpicture}
\item L has all strings w such that w any string of 1's and 0's except 11 and 111
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial, accepting] (q_0) {$q_0$};
\node[state](q_1) [below right=of q_0] {$q_1$};
\path[->]
(q_0)
edge node {0} (q_1)
edge [loop above] node {1} ()
(q_1) edge [loop above] node {0} ();
\end{tikzpicture}
\item L has all strings w such that w contains at least two 0's and at most one 1
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial, accepting] (q_0) {$q_0$};
\node[state](q_1) [below right=of q_0] {$q_1$};
\path[->]
(q_0)
edge node {0} (q_1)
edge [loop above] node {1} ()
(q_1)
edge [loop above] node {0} ();
\end{tikzpicture}
\end{enumerate}
\pagebreak
\end{document}
答案1
你有过
\node[state] (q_1) [below right=of q_1] {$q_1$};
但它应该是
\node[state] (q_1) [below right=of q_0] {$q_1$};
您需要使用已经存在的节点名称来相对放置其他节点。您尝试使用q_1
来放置q_1
,但这触发了错误。
完整代码(精简):
\documentclass[12pt]{article}
\usepackage{latexsym}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{center}
Theory of Computation, SPRING 2015 \\
Homework Problems\\
\end{center}
\smallskip
\begin{enumerate}
\item L has all strings w such that w does not contain 101
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial, accepting] (q_0) {$q_0$};
\node[state] (q_1) [below right=of q_0] {$q_1$};
\path[->]
(q_0)
edge node {0} (q_1)
edge [loop above] node {1} ()
(q_1)
edge [loop above] node {0} ();
\end{tikzpicture}
\item L has all strings w such that w any string of 1's and 0's except 11 and 111
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial, accepting] (q_0) {$q_0$};
\node[state](q_1) [below right=of q_0] {$q_1$};
\path[->]
(q_0)
edge node {0} (q_1)
edge [loop above] node {1} ()
(q_1) edge [loop above] node {0} ();
\end{tikzpicture}
\item L has all strings w such that w contains at least two 0's and at most one 1
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial, accepting] (q_0) {$q_0$};
\node[state](q_1) [below right=of q_0] {$q_1$};
\path[->]
(q_0)
edge node {0} (q_1)
edge [loop above] node {1} ()
(q_1)
edge [loop above] node {0} ();
\end{tikzpicture}
\end{enumerate}
\end{document}