Drawing graphs and automata in LaTeX

September 21, 2006

I am currently enrolled in a class entitled “Automata, Computability, and Formal Languages” at UNO. It’s a neat class. The professor requires us to submit our homework in both hard and soft copies. Naturally, he suggests we use LaTeX to typeset our homework.

Given that this is a class on automata, I end up drawing a lot of state diagrams to represent the machines I have to design for the problems. I wanted a nice way to draw these and put them in to my LaTeX document. The first thing I did was check to see if OmniGraffle exported to EPS, and it did. LaTeX can read EPS, so I was okay if I couldn’t find anything better.

With a solution in hand, I started to look and see if there was anything I could use to typeset these graphs right in the LaTeX source itself. Preferably something designed for drawing finite state-machines, even. What I found was GasTeX. It is a decently cool package.

The following source code from their samples page:

    \begin{picture}(15, 28)(0,-10)
    \drawloop[loopangle=270](A0){$a, b$}
  \caption{La complétion de l'automate.}

Generates this graph (which I have scaled down):

Example of GasTeX output

Example of GasTeX output

One note about this snippet, though, is that I did not have to use the center environment to center the figures. Instead I used the \centering directive inside my figure environment, and that worked nicely.

It’s nice to use and it makes pretty graphs. I’ll be using it for the rest of the semester, that’s for sure!

Layout, design, graphics, photography and text all © 2005-2010 Samuel Tesla unless otherwise noted.

Portions of the site layout use Yahoo! YUI Reset, Fonts & Grids.