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.

What's the best way to draw UML class diagrams in LaTeX?

share|improve this question
4  
Would you mind adding a little context, or a link to a description or (better still) a picture of the sort of thing that you'd like? Someone may be able to help but not know what a UML diagram is. Thanks! –  Loop Space Aug 3 '10 at 9:19
1  
UML stands for unified modelling language. en.wikipedia.org/wiki/… –  Willie Wong Aug 3 '10 at 11:58

7 Answers 7

up vote 43 down vote accepted
  • MetaUML is a MetaPost library for typesetting UML diagrams with a human-friendly textual notation. Another useful package is emp. It allows to embed Metapost code and therefore MetaUML inside a LaTeX document
  • pst-uml is a PSTricks package providing support for drawing UML diagrams.
  • uml is another package using PSTricks implementing at least a subset
  • pgf/TikZ is so feature rich that it can be used for typesetting UML diagrams as well
  • tikz-uml is a UML-specialized TikZ package
share|improve this answer
2  
My guess would be that this is the sort of algorithmic-drawing example where Metapost would be a natural choice, but that fits for GraphViz, too. –  Norman Gray Aug 3 '10 at 14:24
    
See Giel's answer for a pgl library. –  Kevin Vermeer Aug 5 '10 at 1:41
1  
+1 MetaUML looks really nice both the syntax and the output. –  Johan Nov 14 '10 at 13:47

For UML class diagrams I'd recommend pgf-umlcd, for sequence diagrams pgf-umlsd. Both packages are based on the PGF package collection, which I find very easy to use for drawing vector graphics within TeX & LaTeX.

share|improve this answer
    
Your link is broken, there's some extra text at the end. –  philosodad Oct 28 '10 at 18:06
    
Try this link instead: loria.fr/~quinson/blog/2010/11/05/UML_class_diagrams_in_tikz –  yegor256 Feb 24 '11 at 9:14
    

(Lifted from Dima's answer to my question on flowcharts.) You can also use the Dot language and GraphViz. With UMLGraph you can generate GraphViz specs, and use dot2tex or Mark Aufflick's graphviz.sty to embed the graphs into LaTeX.

share|improve this answer
    
auto-upvote =))))) –  Dima Aug 3 '10 at 16:19

A nice package I found a while ago is this: TikZ-UML.

It provides:

  • Class diagrams.
  • Use cases.
  • State-transitions.
  • Sequence diagrams.

It works pretty well, at least with the sequence diagrams I used.

share|improve this answer

While I guess there are nicer ways to do it, I recently came across this example on texample.net on one way to produce UML diagrams with TikZ.

share|improve this answer

Tangentially related to Willie's answer, if you think you might use graphviz to generate the diagrams, you might consider doxygen.

This approach would be especially handy if you have more documentation than just the diagrams to create. Doxygen is intended to document software projects. If you have a set of classes in C++ or java, then you can use doxygen to generate latex from the source code. It can automatically generate several types of diagrams from the source, including UML class diagrams all hyperlinked and integrated with the rest of the documentation and its source code.

share|improve this answer

For what it's worth, yet another option is PlantUML.

PlantUML takes pseudo-code-y plain-text class descriptors and generates UML diagrams (as PNG, SVG or EPS, possibly others). It's a Java-based program that used Graphviz on the back-end to determine layouts.

In addition to class/object diagrams, PlantUML can also generate other UML diagrams like sequence, activity, state, use case diagrams.

There's nothing particularly LaTeX-specific about it, and you'll probably need or want to store the class descriptors in an independent file but I've often used PlantUML (or for that matter, ditaa) as part of a LaTeX publishing workflow.

share|improve this answer

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.