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 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

share|improve this question
    
Could you please provide a complete minimal working example. –  N.N. Jun 17 '11 at 8:31
    
NN: Edited. Thank you. –  Chan Jun 17 '11 at 8:32
add comment

2 Answers

up vote 5 down vote accepted
\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

share|improve this answer
    
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 9: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. –  Chan Jun 17 '11 at 9:48
add comment

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

share|improve this answer
    
Nice one ;) Thanks a lot. By the way, how can I add text below the bracket? Could you help? –  Chan Jun 17 '11 at 9:54
    
@Chan: you can find the solution in this question –  Ignasi Jun 17 '11 at 10:14
    
Many thanks. –  Chan Jun 17 '11 at 10:51
add comment

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.