LATEX - 如何在一个循环箭头上显示多个转换?
LATEX - how to display many transitions on one loop arrow?
我想在乳胶中的一个循环箭头上显示许多转换。我现在这样做的方式是,3 行显示在另一行之上。如何在同一循环中的 3 条不同的线上显示这三条线?
\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=4cm,
semithick]
\tikzstyle{every state}=[draw=black,text=black]
\node[initial by arrow,state,initial text=] (1) {1};
\node[state] (2) [right of=1] {2};
\node[state] (3) [right of=2] {3};
\node[state, accepting] (4) [right of=3] {4};
\path
(1) edge node {$\epsilon,\epsilon;\#$} (2)
(2) edge [loop above] node {$a,\epsilon; x$} (2)
(2) edge [loop above] node {$b, \epsilon; \epsilon$} (2)
(2) edge [loop above] node {$$,\epsilon; \epsilon$} (2)
(2) edge node {$$,\epsilon; \epsilon$} (3)
(3) edge [loop below] node {$b,a; \epsilon $} (3)
(3) edge [loop below] node {$a,\epsilon; \epsilon $} (3)
(3) edge [loop below] node {$$,\epsilon;\epsilon $} (3)
(3) edge node {$\epsilon,\#;\epsilon$} (4)
;
\end{tikzpicture}
您不能在节点中手动换行。但是,如果您指定足够小的文本宽度,则会出现换行符。您甚至可以使用 \mbox 和 \hspace 对其进行精细控制。
你的情况很简单。只需在节点
中添加[text width=something_small]
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata}
\begin{document}
\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=4cm,
semithick]
\tikzstyle{every state}=[draw=black,text=black]
\node[initial by arrow,state,initial text=] (1) {1};
\node[state] (2) [right of=1] {2};
\node[state] (3) [right of=2] {3};
\node[state, accepting] (4) [right of=3] {4};
\path
(1) edge node {$b,\epsilon;\#$} (2)
(2) edge [loop above] node[text width=1cm] {$a,\epsilon; x$
$b, \epsilon; \epsilon$} (2)
(2) edge node {$$,\epsilon; a$} (3)
(3) edge [loop below] node[text width=1cm] {$b,a; \epsilon $
$$,\epsilon;\epsilon $} (3)
(3) edge node {$\epsilon,\#;\epsilon$} (4)
;
\end{tikzpicture}
\end{document}
我想在乳胶中的一个循环箭头上显示许多转换。我现在这样做的方式是,3 行显示在另一行之上。如何在同一循环中的 3 条不同的线上显示这三条线?
\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=4cm,
semithick]
\tikzstyle{every state}=[draw=black,text=black]
\node[initial by arrow,state,initial text=] (1) {1};
\node[state] (2) [right of=1] {2};
\node[state] (3) [right of=2] {3};
\node[state, accepting] (4) [right of=3] {4};
\path
(1) edge node {$\epsilon,\epsilon;\#$} (2)
(2) edge [loop above] node {$a,\epsilon; x$} (2)
(2) edge [loop above] node {$b, \epsilon; \epsilon$} (2)
(2) edge [loop above] node {$$,\epsilon; \epsilon$} (2)
(2) edge node {$$,\epsilon; \epsilon$} (3)
(3) edge [loop below] node {$b,a; \epsilon $} (3)
(3) edge [loop below] node {$a,\epsilon; \epsilon $} (3)
(3) edge [loop below] node {$$,\epsilon;\epsilon $} (3)
(3) edge node {$\epsilon,\#;\epsilon$} (4)
;
\end{tikzpicture}
您不能在节点中手动换行。但是,如果您指定足够小的文本宽度,则会出现换行符。您甚至可以使用 \mbox 和 \hspace 对其进行精细控制。
你的情况很简单。只需在节点
中添加[text width=something_small]\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata}
\begin{document}
\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=4cm,
semithick]
\tikzstyle{every state}=[draw=black,text=black]
\node[initial by arrow,state,initial text=] (1) {1};
\node[state] (2) [right of=1] {2};
\node[state] (3) [right of=2] {3};
\node[state, accepting] (4) [right of=3] {4};
\path
(1) edge node {$b,\epsilon;\#$} (2)
(2) edge [loop above] node[text width=1cm] {$a,\epsilon; x$
$b, \epsilon; \epsilon$} (2)
(2) edge node {$$,\epsilon; a$} (3)
(3) edge [loop below] node[text width=1cm] {$b,a; \epsilon $
$$,\epsilon;\epsilon $} (3)
(3) edge node {$\epsilon,\#;\epsilon$} (4)
;
\end{tikzpicture}
\end{document}