Latex/tikz support

+3 votes
asked Apr 9, 2014 in Wanted features by plantuml (143,890 points)
edited May 5, 2014 by plantuml

Some users have asked for latex/tikz support.

So here is an beta version that has "-tlatex" flags in its command line.

We have choosen a simple diagram:

class Subscriber {
class AccumUsage {
class IpSession {
Subscriber "1" --> "1..*" IpSession
Subscriber "1" --> "0..1" AccumUsage

The goal of this test is to generate a tikz file like this :

\draw (131pt,29pt) rectangle (223pt,90.8359pt);
\node at (160pt,37.4531pt)[below right]{Subscriber};
\draw (132pt,61pt) -- (222pt,61pt);
\node at (137pt,65pt)[below right]{subscriberId};
\draw (132pt,82.8359pt) -- (222pt,82.8359pt);
\draw (31pt,212pt) rectangle (137pt,273.8359pt);
\node at (60pt,220.4531pt)[below right]{AccumUsage};
\draw (32pt,244pt) -- (136pt,244pt);
\node at (37pt,248pt)[below right]{subscriberId};
\draw (32pt,265.8359pt) -- (136pt,265.8359pt);
\draw (221pt,191pt) rectangle (318pt,294.3438pt);
\node at (254.95pt,199.4531pt)[below right]{IpSession};
\draw (222pt,223pt) -- (317pt,223pt);
\node at (227pt,227pt)[below right]{ipAddress};
\node at (227pt,240.8359pt)[below right]{specificData};
\node at (227pt,254.6719pt)[below right]{sapcOriginStateId};
\node at (227pt,268.5078pt)[below right]{apnId};
\draw (222pt,286.3438pt) -- (317pt,286.3438pt);
\draw (191.942pt,90.081pt) ..controls (205.204pt,115.893pt) and (224.952pt,154.325pt) .. (241.265pt,186.076pt);
\node at (191.0584pt,98.9168pt)[below right]{1};
\node at (230.3817pt,166.6703pt)[below right]{1..*};
\draw (162.058pt,90.081pt) ..controls (145.645pt,122.023pt) and (119.302pt,173.295pt) .. (101.824pt,207.31pt);
\node at (143.0082pt,98.7264pt)[below right]{1};
\node at (101.801pt,187.522pt)[below right]{0..1};


Works is still in progress...

See also

4 Answers

0 votes
answered Jun 25, 2014 by anonymous

If this is the place to post bug reports on the Latex/tikz generation, the following simple file (lets call it test.uml) causes a NullPointerException:

class Foo
class Bar <|-- Foo
I am using the following command line: java -jar plantuml.jar -tlatex test.uml. Generating other formates (e.g., PNG) works as expected.
I've uploaded the full traceback here:
commented Jun 25, 2014 by plantuml (143,890 points)
It's the right place, thanks for the report.
We have solved this bug in the following beta:
Feel free to go on if you find any other issues (we've made almost no tests on the latex export).

0 votes
answered Apr 2, 2015 by Pierre.Sassoulas (370 points)
I don't know if it's working as intended but when there is special latex character in the plantuml code, the generated latex won't compile.

For example:

title any_string_with_underscore

It generate :

% generated by Plantuml 8021

\node at (0pt,0pt)[below right]{any_string_with_underscore};

So you get an error with pdflatex :

! Missing $ inserted.
<inserted text>
l.6 \node at (0pt,0pt)[below right]{any_

If you add backslashs it works (any\_string\_with\_underscore)
commented Apr 2, 2015 by plantuml (143,890 points)
Thanks for the feedback, this is a bug.
There is a beta version here that fixes it:

By the way, we are in the middle of something. We'd like to use real guillemot instead of << and >> for rendering.

So with this beta, if you test:

title any_string_with_underscore
actor foo << Foo >>

You'll see that in the Latex code, we are now using \usepackage{aeguill} and the commands \guillemotleft \guillemotright
Any though about this?

Do not hesitate to post here if you find other issues with Latex : very few tests have been done.

commented Apr 2, 2015 by Pierre.Sassoulas (370 points)
edited Apr 3, 2015 by Pierre.Sassoulas
The <<>> replacement looks fine to me, but I know what it is supposed to replace so maybe I'm prejudiced.

Another remark maybe : it would be possible to insert everything into a figure environnement and make the title "any_string_with_underscore" as the caption (maybe with an automatic label) ?

Like this :

\caption{\label{fig:plantuml-any_string_with_underscore} any\_string\_with\_underscore}

I think that in most case you want to export to latex because you will use the diagram in your document and it will be inside a figure and the title of the diagram should be the caption.

 I think resizing the figure would be nice too because rigth now a figure can go way above the limit of the page. Edit : This is not simple at all to do in latex the text does not adapt well when you use scale in the tikz figure, and I don't think there is a simple solution to this.
0 votes
answered May 14, 2017 by anonymous

Extending a use case to another use case will generate a solid arrow instead of dashed arrow. My workaround: edit the generated LaTeX code manually by adding "dashed" inside the \draw[...].

Great work by the way. PlantUML really helps me.
0 votes
answered Jan 9 by hhhannes (190 points)


I cannot run 

plantuml -v -tlatex:nopreamble life-cycle.pum

on this simple diagram. Are you able to reproduce and fix?

The error message is shown below.





digraph foo {

node [style=rounded]

node1 [shape=box]

node2 [fillcolor=yellow, style="rounded,filled", shape=diamond]

node3 [shape=record, label="{ a | b | c }"]

node1 -> node2 -> node3




(0.000 - 245 Mo) 237 Mo - PlantUML Version 1.2018.00

(0.019 - 245 Mo) 237 Mo - GraphicsEnvironment.isHeadless() false

(1.868 - 245 Mo) 234 Mo - Setting current dir: .

(1.868 - 245 Mo) 234 Mo - Setting current dir: /Users/jo/dev/master/thesis/assets/plantuml

(1.869 - 245 Mo) 234 Mo - Using default charset

(1.874 - 245 Mo) 234 Mo - Setting current dir: /Users/jo/dev/master/thesis/assets/plantuml

(1.886 - 245 Mo) 233 Mo - Setting current dir: /Users/jo/dev/master/thesis/assets/plantuml

(1.887 - 245 Mo) 233 Mo - Reading file: assets/plantuml/life-cycle.puml

(2.203 - 245 Mo) 220 Mo - Creating file: /Users/jo/dev/master/thesis/assets/plantuml/life-cycle.latex

(2.207 - 245 Mo) 218 Mo - Starting Graphviz process [/usr/local/opt/graphviz/bin/dot, -Tlatex_no_preamble]

(2.207 - 245 Mo) 218 Mo - DotString size: 198

(2.238 - 245 Mo) 217 Mo - Ending process ok

(2.238 - 245 Mo) 217 Mo - Ending Graphviz process

Exception in thread "main" java.lang.UnsupportedOperationException

at net.sourceforge.plantuml.ugraphic.UGraphicUtils.writeImage(

at net.sourceforge.plantuml.directdot.PSystemDot.exportDiagramNow(

at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(

at net.sourceforge.plantuml.PSystemUtils.exportDiagramsDefault(

at net.sourceforge.plantuml.PSystemUtils.exportDiagrams(

at net.sourceforge.plantuml.SourceFileReader.getGeneratedImages(

at net.sourceforge.plantuml.Run.manageFileInternal(

at net.sourceforge.plantuml.Run.processArgs(

at net.sourceforge.plantuml.Run.manageAllFiles(

at net.sourceforge.plantuml.Run.main(
commented Jan 9 by plantuml (143,890 points)
Unfortunately, export to LaTeX works only with UML diagrams.
Your diagram is a GraphViz/Dot one.
Sorry about that!