如何从右侧启动开始符号?

如何从右侧启动开始符号?

当制作自动机时,我希望起始符号从右边开始而不是从左边开始,因为起始符号与线相撞:

\documentclass[a4paper,8pt]{article}
\usepackage{amssymb,amsthm}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{graphicx}
%\usepackage{slashbox}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}
\usepackage{qtree}
\newtheorem{thm}{Theorem}[section]
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lemma}[thm]{Lemma}
\newtheorem*{defi}{Definition}
\linespread{1.2}
\usepackage{qtree}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{automata,positioning,decorations.markings,arrows}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}

\begin{document}
Reverse:\\
\begin{tikzpicture}[shorten >=2pt,node distance=2cm,on grid,auto]
\node[state,accepting](s) {$s$};
\node[state](q_0) [right=of s] {$q_0$};
\node[initial,state](q_1) [right=of q_0] {$q_1$};
\node[state](q_2) [below=of s] {$q_2$};
\node[state ](q_3) [below=of q_2] {$q_3$};
\path[->]
(q_0) edge node{a} (s)
(q_1) edge node{b} (q_0)
edge [loop above ] node {b} ()
(q_3) edge  node {a} (q_1)
edge [loop below ] node {a} ()
(q_2) edge node{b} (s)
(q_3) edge node{a} (q_2)
(q_2) edge [loop right ] node {a} ()
(q_2) edge [bend left =30] node {b} (q_3);
\end{tikzpicture}
\end{document}

答案1

您可以使用intial where={right}。完整的示例:

\documentclass[a4paper,8pt]{article}
\usepackage{amssymb,amsthm}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{graphicx}
%\usepackage{slashbox}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}
\usepackage{qtree}
\newtheorem{thm}{Theorem}[section]
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lemma}[thm]{Lemma}
\newtheorem*{defi}{Definition}
\linespread{1.2}
\usepackage{qtree}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{automata,positioning,decorations.markings,arrows}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}

\begin{document}
Reverse:\\
\begin{tikzpicture}[shorten >=2pt,node distance=2cm,on grid,auto]
\node[state,accepting](s) {$s$};
\node[state](q_0) [right=of s] {$q_0$};
\node[initial,state,initial where={right}](q_1) [right=of q_0] {$q_1$};
\node[state](q_2) [below=of s] {$q_2$};
\node[state ](q_3) [below=of q_2] {$q_3$};
\path[->]
(q_0) edge node{a} (s)
(q_1) edge node{b} (q_0)
edge [loop above ] node {b} ()
(q_3) edge  node {a} (q_1)
edge [loop below ] node {a} ()
(q_2) edge node{b} (s)
(q_3) edge node{a} (q_2)
(q_2) edge [loop right ] node {a} ()
(q_2) edge [bend left =30] node {b} (q_3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容