我想在乳胶的一个循环箭头上显示许多转换。我现在的操作方式是,三行显示在另一行之上。如何在同一循环中的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}
答案 0 :(得分:1)
您不能在节点中手动断行。但是,如果您指定足够小的文本宽度,则会出现换行符。您甚至可以使用\ 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}