I'm writing a paper about classes of formal languages, and I'd like to have a diagram showing their heirarchy.

Something similar to this (from Wikipedia:) enter image description here

Is there a LaTeX package which, I can give the relationship between the classes to, and have automatically generate and lay-out a venn-diagram for me?

The idea is that I would give it the list of classes, and some relations between them, i.e. which were contained in each other, which were disjoint, which were incomparable but not disjoint. Containment is assumed to be transitive (i.e. if A is in B, B is in C, then A is in C).

Is there a way to do this programatically, or a package to do it automatically? The idea is that I'm continually adding new classes to the diagram, and would love if it would automatically update itself every time I discovered a new relation.

  • Search for venn diagrams on this site. There are a number of questions & answers, such as tex.stackexchange.com/questions/78730/drawing-a-venn-diagram. I realize your question may go beyond them, in its hopes for automation... May 30, 2013 at 20:07
  • Have you seen How to draw Venn diagrams (especially: complements) in LaTeX?
    – Werner
    May 30, 2013 at 20:08
  • 4
    Drawing these things automatically, given just the inclusion relation, sounds rather ambitious to my mind. You might find the TikZ fit library handy -- given a set of points, you can tell TikZ to draw a shape that encompasses all of them. May 30, 2013 at 20:11
  • 3
    @jmite I think that definitive answer is that it can be done but TikZ is not the right tool or should I say not enough. If I had to bid for the job I would propose PythonTeX as the way to attack this problem (it uses pgf as back-ends for plotting just like TikZ). I would ask a student to write Python parser for the relationship between classes first and when the student makes some progress I would write a PythonTeX wrapper. May 30, 2013 at 21:12
  • An alternative to PythonTex would be to use the package sagetex. This would follow the same than Punosevac's suggestion.
    – boumol
    May 31, 2013 at 8:31


Browse other questions tagged .