I'm looking for a LaTeX package which helps drawing automata problems. I googled and found A package for drawing automata and graphs (Version 0.4). But I'm not sure is this package a standard one, or there are some better alternatives. Any suggestion?

  • 3
    This manual might help you : tug.org/pracjourn/2007-1/joshi/joshi.pdf, only 19 pages and easy to follow. :-) Jun 15, 2011 at 4:48
  • as an alternative u can use GasTeX Apr 24, 2013 at 14:10
  • In its current form this is more a comment. Please add some content. A minimal working example (MWE) and perhaps an image of example output would be good. Note also, that GasTeX is included in both MiKTeX (full installation) and TeX Live, and obviously uploaded on CTAN.
    – Speravir
    Apr 24, 2013 at 15:26
  • This would be a very interesting answer if you could give an example of how it is used (ideally a working example together with a graphic), as the other answerers have done for their recommendations. Apr 25, 2013 at 8:53

3 Answers 3


TiKZ has a whole library for drawing automata:


\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
   \node[state,initial] (q_0)   {$q_0$}; 
   \node[state] (q_1) [above right=of q_0] {$q_1$}; 
   \node[state] (q_2) [below right=of q_0] {$q_2$}; 
   \node[state,accepting](q_3) [below right=of q_1] {$q_3$};
    (q_0) edge  node {0} (q_1)
          edge  node [swap] {1} (q_2)
    (q_1) edge  node  {1} (q_3)
          edge [loop above] node {0} ()
    (q_2) edge  node [swap] {0} (q_3) 
          edge [loop below] node {1} ();

output of code

  • 2
    I love that picture ^_^! Very nice and clear, thanks a lot.
    – roxrook
    Jun 15, 2011 at 10:24
  • 3
    I second @Alan on Tikz. I used vaucanson-g for some time and IMHO it lacks lots of features in which Tikz is quite trivial to achieve. The Tikz manual has great examples on how to tweak automata drawings. Jun 15, 2011 at 11:02
  • I tried this example, and in the output file there isn't the automata. What i have in the output document is the string start, where letters s and t are covered with a scribble. Why i get this result? Mar 21, 2014 at 8:46
  • @frenk I would suspect this is due to using a DVI previewer. Does the PDF file created look the same way if you open it in a PDF previewer?
    – Alan Munn
    Mar 21, 2014 at 22:19

using xy-pic package available at ctan for automata diagrams. enter image description here

*+<1pc>[o][F-]{q_0}  \ar@(l,l)[]^<<<<{start} \ar@/^/[r]^0  \ar@/_/[d]_1 
& *+<1pc>[o][F-]{q_1} \ar@(ul,ur)[]^{0}  \ar@/^/[d]^1 \\
*+<1pc>[o][F-]{q_2} \ar@(dr,dl)[]^{1} \ar@/_/[r]_0 
& *+<1pc>[o][F=]{q_3} }
  • 9
    I've got to be honest: that is the most Perl-y syntax I've ever seen from TeX. I know this is an old post, but could you explain the syntax a little bit if you have time? :) Jun 26, 2014 at 1:11
  • 5
    @SeanAllred To be frank with you, even i don't remember the syntax, it's highly abstract unlike tikz, I was trying to practice at that time of posting answer. For a quick learning you may refer to this nice presentation. math.arizona.edu/~swig/documentation/xypic/Xypic.pdf and more detailed at userguide Jun 30, 2014 at 0:32

If you want great diagrams without having to write the code for it, check out this tool:


You can make your diagram by clicking and dragging, then export it as LaTeX (it uses TiKZ, just like the answer by @Alan Munn).

  • I like this tool, and would use it, but it doesn't seem to be able to write the text/input in the middle of the transition arrow?
    – delrocco
    Feb 3, 2019 at 5:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .