What's the best way to draw UML class diagrams in LaTeX?
- 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-umlis a PSTricks package providing support for drawing UML diagrams.
umlis 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-umlis a UML-specialized TikZ package
A nice package I found a while ago is this: TikZ-UML.
- Class diagrams.
- Use cases.
- Sequence diagrams.
It works pretty well, at least with the sequence diagrams I used.
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.
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 uses 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.
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.