What's the best way to draw UML class diagrams in LaTeX?
-
5Would 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! – Andrew Stacey Aug 03 '10 at 09:19
-
5UML stands for unified modelling language. http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview – Willie Wong Aug 03 '10 at 11:58
8 Answers
- 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
- 103
- 1
- 5
- 231,401
-
6My 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 03 '10 at 14:24
-
-
2
-
1I highly recommend tikz-uml, very flexible, comprehensive and nice looking. Support the author, please. All other packages are very old (last, about 2006) and based on old packages,... pgf-Tikz is too generic. – user14416 Apr 26 '15 at 17:54
For UML class diagrams I'd recommend pgf-umlcd, for sequence diagrams pgf-umlsd (example by the author). Both packages are based on the PGF package collection, which I find very easy to use for drawing vector graphics within TeX & LaTeX.
- 206,688
- 1,753
-
-
Try this link instead: http://www.loria.fr/~quinson/blog/2010/11/05/UML_class_diagrams_in_tikz/ – yegor256 Feb 24 '11 at 09:14
-
Correct link is now: http://www.loria.fr/~quinson/blog/2010/1105/UML_class_diagrams_in_tikz/. TeXample using pgf-umlsd: http://www.texample.net/tikz/examples/pgf-umlsd/ – przemoc Jul 12 '11 at 13:47
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.
- 2,455
-
1The install section says "coming soon" for probably quite a while already. Don't be discouraged, the downloadable archive contains nice examples. – BadAtLaTeX Mar 13 '18 at 14:54
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.
- 181
- 1
- 3
-
i recommend the
epsformat to export, because its lossless and latex can use it natively – Ohmen Mar 06 '20 at 16:59
(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.
- 24,733
- 8
- 74
- 106
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.
- 89,023
- 26
- 255
- 291
-
The nice thing about this is that it doesn't break TikZ relative positioning .. some of the other solutions appear to require manual positioning of all elements. – M Juckes Oct 03 '20 at 08:28
-
I had problems with \draw{myarrow} trying to replicate the example. I got the error _! Argument of \language@active@arg> has an extra }.
\par l.230 \draw[myarrow] (CoolingSystem.north) -- ++(0,0.8) -| (System.south);_ – rvcristiand Jan 02 '21 at 01:56 -
I fix it. http://algunostutoriales.blogspot.com/2014/03/arreglar-un-extrano-error-de-latex.html – rvcristiand Jan 02 '21 at 14:33
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.
- 1,313
- 223