6

I tried to add a curly braces below all the states in order to group them, but I couldn't find a way to make it work. Furthermore, how could I draw a three dots as a state since I need to prove a theorem by induction on n. Here is what I have so far.

\documentclass[10pt,letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}

\begin{document}
    \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
        \node[state,initial]                (q_0)                           {$a$};
        \node[state]                        (q_1)   [right=of q_0]          {$a^2$};
        \node[state]                        (q_2)   [right=of q_1]          {$a^3$};
        \node[state,accepting]              (q_3)   [right=of q_2]          {$a^n$};    

        \path[->]
        (q_0)   edge                        node {a}            (q_1)  
        (q_1)   edge                        node {a}            (q_2) 
        (q_2)   edge                        node {...}          (q_3) 
        (q_3)   edge    [loop above]        node {a}            (q_3)
        ; %end path 
    \end{tikzpicture}   \\
\end{document}  

This is the picture that illustrates what I meant: enter image description here

Thank you

David Carlisle
  • 757,742
roxrook
  • 9,907

2 Answers2

13

Just a little change over Altermundus' answer with \dots being an state.

\documentclass[10pt,letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{automata,positioning,decorations.pathreplacing}

\begin{document}
    \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
    \node[state,initial] (q_0) {$a$};
    \node[state] (q_1) [right=of q_0] {$a^2$};
    \node[state] (q_2) [right=of q_1] {$a^3$};
      \node        (q_dots) [right=of q_2] {$\cdots$}; 
    \node[state,accepting] (q_3) [right=of q_dots] {$a^n$};    

    \path[->]
    (q_0) edge node {a} (q_1)  
    (q_1) edge node {a} (q_2) 
    (q_2) edge  node {a} (q_dots) 
    (q_dots) edge node{a} (q_3)
    (q_3) edge [loop above] node {a} (q_3)
    ; %end path 

\draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=10pt},yshift=0pt]
(q_0.south west) -- (q_3.south east);

\end{tikzpicture}   \\
\end{document}

enter image description here

David Carlisle
  • 757,742
Ignasi
  • 136,588
5
\documentclass[10pt,letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,automata,calc,positioning}

\begin{document}
    \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
        \node[state,initial]                (q_0)                           {$a$};
        \node[state]                        (q_1)   [right=of q_0]          {$a^2$};
        \node[state]                        (q_2)   [right=of q_1]          {$a^3$};
        \node[state,accepting]              (q_3)   [right=of q_2]          {$a^n$};    

        \path[->]
        (q_0)   edge                        node {a}            (q_1)  
        (q_1)   edge                        node {a}            (q_2) 
        (q_2)   edge                        node {...}          (q_3) 
        (q_3)   edge    [loop above]        node {a}            (q_3)
        ; %end path 
\draw[decorate,decoration={brace,mirror,raise=6pt}, thick] ($(q_0.south west)+(-1.5,0)$)--(q_3.south east);  
    \end{tikzpicture}  

\end{document} 

enter image description here

Alain Matthes
  • 95,075
  • I don't know automata library perhaps there is a node for start to avoid +(-1.5,0). I know it's possible to define intial distance so in this case you know the distance between start and the first node. Well, you need to read the pgfmanual about this library to customize the answer. – Alain Matthes Jun 17 '11 at 09:34
  • Thanks a lot. Yeah I really want to get rid of the start, but I've just used TikZ for a day. I will look it up. – roxrook Jun 17 '11 at 09:48