Welcome to PlantUML Q&A, where you can ask questions and receive answers from other members of the community.

You can also submit new features request and vote for them.

Latex/tikz support

+2 votes

Some users have asked for latex/tikz support.

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

https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

We have choosen a simple diagram:

@startuml
class Subscriber {
  subscriberId
}
class AccumUsage {
  subscriberId
}
class IpSession {
  ipAddress
  specificData
  sapcOriginStateId
  apnId
}
Subscriber "1" --> "1..*" IpSession
Subscriber "1" --> "0..1" AccumUsage
@enduml


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

https://www.writelatex.com/read/pgkkspzgzgpb

\documentclass{article}
\usepackage{tikz}
%
\begin{document}
\begin{tikzpicture}[yscale=-1]
\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};
\end{tikzpicture}
\end{document}

 

Works is still in progress...
 

See also http://plantuml.sourceforge.net/latex.html

asked Apr 9, 2014 in Wanted features by plantuml (112,860 points)
edited May 5, 2014 by plantuml

2 Answers

0 votes

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:

@startuml
class Foo
class Bar <|-- Foo
@enduml
 
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: http://hastebin.com/otesifiyil
answered Jun 25, 2014 by anonymous
It's the right place, thanks for the report.
We have solved this bug in the following beta:
https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
Feel free to go on if you find any other issues (we've made almost no tests on the latex export).

Regards,
0 votes
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:

@startuml
title any_string_with_underscore
@enduml

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_
                                        string_with_underscore};
?

If you add backslashs it works (any\_string\_with\_underscore)
answered Apr 2, 2015 by Pierre.Sassoulas (370 points)
Thanks for the feedback, this is a bug.
There is a beta version here that fixes it:
https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

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:

@startuml
title any_string_with_underscore
actor foo << Foo >>
@enduml

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.

Regards,
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 :
\begin{figure}

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

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.
Support This Project Offer 250 Mo! Follow PlantUML on Twitter
...