I am currently using Tikz in order to draw a finite automata. I would need to add an arrow from a bit of text to one of the nodes of the finite automata, as shown in the example.
I have tried created a node with "draw=none". However, this raises two problems. I am unable to write the text desired on two lines and further more, the bounding box for the node is created, although not displayed and thus, the arrow looks really bad, since the bounding box for such a long text is huge.
\documentclass[11pt]{report}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows, automata}
\begin{document}
(not important stuff)
\begin{tikzpicture}[->,>=stealth', shorten >=1pt, auto, node distance=2.8cm, semithick]
\node[state] (A) {$Alarm$};
\node[state] (B) [above of=A] {$Reset$};
\node[state] (C) [above right of=A] {$S1$};
\node[state] (D) [right of=A] {$S2$};
\node[state] (E) [below right of=A] {$S3$};
\node[state] (F) [below of=A] {$S4$};
\node[state] (G) [left of=A] {$Open$};
\node[statem, draw=none] (H) [above left of=B] {Reset input(from any state)};
\path (A) edge [loop left] node {0, 1} (A)
(B) edge [bend left] node {1} (C)
edge node {0} (A)
(C) edge [bend left] node {0} (D)
edge node {1} (A)
(D) edge [bend left] node {1} (E)
edge node {0} (A)
(E) edge [bend left] node {1} (F)
edge node {0} (A)
(F) edge [bend left] node {0} (G)
edge node {1} (A)
(G) edge [bend left] node {0} (B)
edge [loop left] node {1} (G)
(H) edge node {} (B);
\end{tikzpicture}
(more not important stuff)
\end{document}
PS Knowing how to move the arrows to the middle of the edge would also be appreciated(at the present time they are at the end of the edge).
Best Answer
Here's one possibility using the
automata
library and a decoration to place the arrows in the middle of the edges:The code:
There's an
initial
style (refer to the documentation), but I opted for a simple\node
with some attributes to place the "Reset input (from any state)" text.And here's a modified version for the code in the question, using the same ideas as before: