Latex/tikz support

+2 votes
asked Apr 9, 2014 in Wanted features by plantuml (134,510 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

3 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 (134,510 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 (134,510 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 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.