Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to draw this automaton:

enter image description here

But I drew it with a bad way !!

\documentclass{article}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\usepackage[latin1]{inputenc}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,semithick]
\node[initial,state] (A) {$1$};
\node[state] (B) [right of=A] {$2$};
\node[state] (C) [right of=B] {$3$};
\node[state] (D) [right of=C] {$4$};
\node[state,accepting] (E) [right of=D] {$5$};
\node[state,accepting] (F) [below of=E] {$6$};
\node[state,accepting] (G) [below of=D] {$7$};
\node[state,accepting] (H) [below of=G] {$8$};
\node[state,accepting] (I) [below of=H] {$9$};
\node[state] (J) [below of=A] {$10$};
\node[state,accepting] (P) [below of=J] {$16$};
\node[state] (K) [below left of=I] {$11$};
\node[state] (L) [right of=K] {$12$};
\node[state,accepting] (M) [right of=L] {$13$};
\node[state,accepting] (N) [below of=L] {$14$};
\node[state,accepting] (O) [below of=M] {$15$};
\node[state,accepting] (Q) [below of=B] {$17$};
\path (A) edge node {X}(B)
          edge node{I} (C)
          edge node{V} (J)
      (B) edge [loop above] node {X}(B)
          edge node{I} (C)
          edge node{V} (J)
          edge node{<>I,<>V} (Q)
      (C) edge node {X}(H)
          edge node{I} (D)
          edge node{V} (G)
          edge node{Autre} (I)
      (D) edge node {I}(E)
          edge node{<>I} (F)
      (J) edge node {I}(K)
          edge node{<>I} (P)
      (K) edge node {I}(L)
          edge node{<>I} (N)
      (L) edge node {I}(M)
          edge node{<>I} (O);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this question
1  
you can use edge[bend left] etc. –  Leo Liu May 2 '13 at 1:38
    
How can I draw a transition between state 1 and 3 ? –  user29570 May 2 '13 at 1:42
add comment

1 Answer

up vote 3 down vote accepted

You can add bend left or bend right or bend left=<degree> or bend right=<degree> to the edges. Here is an example:

\usetikzlibrary{positioning,automata}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid]
  \node[state,initial]   (q_0)                {$q_0$};
  \node[state]           (q_1) [right=of q_0] {$q_1$};
  \node[state,accepting] (q_2) [right=of q_1] {$q_2$};
  \path[->] (q_0) edge                node [above] {0} (q_1)
                  edge [loop above]   node         {1} ()
                  edge [bend left=45] node [below] {1} (q_2)
                  edge [bend right]   node [below] {0} (q_2)
            (q_1) edge                node [above] {1} (q_2);
\end{tikzpicture}

Result:

enter image description here

share|improve this answer
1  
Try this: \texttt{<>} –  SaltyEgg May 2 '13 at 1:50
1  
@user29570: Try \path (I) +(<x_offset>, <y_offset>) node[state] (K) {$11$}; –  SaltyEgg May 2 '13 at 2:36
1  
@user29570: I'm not sure if this is what you want: Add a line \noindent\hskip -1cm before \begin{tikzpicture}. You can change -1cm to a suitable value. –  SaltyEgg May 2 '13 at 2:59
1  
@user29570: Add a line \vskip -1cm before \noindent\hskip -1cm. BTW, if you add \usetikzpackage{positioning}, you can use relative position like this: [below left=5cm of I]. –  SaltyEgg May 2 '13 at 3:11
1  
Maybe this works: \hbox{}\vskip -1cm –  SaltyEgg May 2 '13 at 3:40
show 9 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.