我想绘制一个具有以下特征的换能器(自动机)。在每个最终状态下,一些边缘会以字母标签离开这些状态,而不会到达任何节点。但我希望能够定义边缘的角度。我该怎么做?
\documentclass[12pt, a4paper, oneside, openany]{memoir}
\usepackage{fontspec}
\usepackage{xgreek}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\setmainfont{Times New Roman}
%automata package
\usepackage{tikz}
\usetikzlibrary{automata, positioning}
\begin{document}
\begin{tikzpicture}[shorten >= 1pt, node distance = 3cm, on grid, auto]
\node [state, initial] (0) {0};
\node [state] (1) [above right=of 0] {1};
\node [state] (2) [below right=of 0] {2};
\node [state, accepting] (3) [above right= of 2] {3};
\path[->]
(0) edge node {a:a} (1)
edge[bend right] node[swap]{b:a} (2)
(1) edge node{a:a} (3)
(2) edge[bend right] node{b:a} (3)
(3) edge node [above] {a} +(2,0);
\end{tikzpicture}
\end{document}
抱歉对齐不好...所以我有一个状态 (3),即接受状态,我希望从三开始的两个边无处可去。但我希望它们的角度不同,比如一个向上,一个向下。我设法添加了一个无处可去的边
(3) edge node [above] {a} +(2,0);
但可以让它改变角度。还有第二个不太相关,请原谅。我可以在我的自动机上添加标题吗
Figure 1
Example of transducer
答案1
只需改变y
坐标:
(3) edge node [right] {a} +(0,2)
(3) edge node [right] {a} +(0,-2);
代码:
\documentclass[12pt, a4paper, oneside, openany]{memoir}
%\usepackage{fontspec}
%\usepackage{xgreek}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
%\setmainfont{Times New Roman}
%automata package
\usepackage{tikz}
\usetikzlibrary{automata, positioning}
\begin{document}
\chapter{one}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[shorten >= 1pt, node distance = 3cm, on grid, auto]
\node [state, initial] (0) {0};
\node [state] (1) [above right=of 0] {1};
\node [state] (2) [below right=of 0] {2};
\node [state, accepting] (3) [above right= of 2] {3};
\path[->]
(0) edge node {a:a} (1)
edge[bend right] node[swap]{b:a} (2)
(1) edge node{a:a} (3)
(2) edge[bend right] node{b:a} (3)
(3) edge node [above] {a} +(2,+1)
(3) edge node [below] {b} +(2,-1);
\end{tikzpicture}
\caption[my figure]{Example of transducer}\label{fig:transducer}
\end{figure}
\end{document}
要获得标题,只需将其封闭tikzpicture
在figure
环境内部。