Git Product home page Git Product logo

plantuml's Introduction

plantuml CTAN

A LuaLaTeX package for PlantUML in LaTeX

PlantUML is a program which transforms text into UML diagrams. This package allows for embedding PlantUML diagrams using the PlantUML source.

Currently, this project runs with lualatex only. Check issue #1 for the current state of affairs for support pdflatex.

Preconditions

  1. Environment variable PLANTUML_JAR set to the location of plantuml.jar. You get it from https://sourceforge.net/projects/plantuml/files/plantuml.jar/download.
  2. Enviroment variable GRAPHVIZ_DOT set to the location of dot.exe. Example: C:\Program Files (x86)\Graphviz2.38\bin\dot.exe. You can install graphviz using choco install graphviz.
  3. lualatex available with command line parameter -shell-escape included.
  4. In case you want to have the images as PDFs (and not using TikZ or PNG), ensure that inkscape.exe and pdfcrop are in your path. You can get inkscape using choco install inkscape. pdfcrop should be part of your latex distribution.

Examples

Minimal Example

LaTeX source:

\documentclass{scrartcl}
\usepackage{plantuml}
\begin{document}
\begin{plantuml}
  @startuml
  Alice -> Bob: test
  @enduml
\end{plantuml}
\end{document}

Compilation: lualatex -shell-escape example-minimal

Result:

Minimal example

Example Class Relations Rendered Using SVG

LaTeX source:

\documentclass{scrartcl}
\usepackage{graphics}
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{
  inkscape -z --file=#1 --export-pdf=\OutputFile
}
\usepackage[output=svg]{plantuml}
\begin{document}
\begin{plantuml}
@startuml
class Car

Driver - Car : drives >
Car *- Wheel : have 4 >
Car -- Person : < owns
@enduml
\end{plantuml}
\end{document}

For newer Inkscape use this LaTeX source:

\documentclass{scrartcl}
\usepackage{graphics}
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{%
  inkscape #1 --export-filename=\OutputFile
}
\usepackage[output=svg]{plantuml}
\begin{document}
\begin{plantuml}
@startuml
class Car

Driver - Car : drives >
Car *- Wheel : have 4 >
Car -- Person : < owns
@enduml
\end{plantuml}
\end{document}

Compilation: lualatex -shell-escape example-class-relations

Result:

Class relations rendered using SVG

Installation

Your latex distribution should take care.

For manual installation, copy plantuml.* to your local texmf folder in the subdirectoy tex/latex/plantuml. See the discussion at tex.sx for the concrete location of the folder on your system.

Development

The release is built using GitHub Actions (workflow file) using release.sh.

Release prepration:

  1. Adapt date and version number in plantuml.sty.
  2. Adapt CHANGELOG.md.
  3. Set a git tag and push.

Alternative Solutions

TikZ-UML is a very powerful package based on TikZ. More alternative solutions are collected at the CTAN topic UML.

License

SPDX-License-Identifier: LPPL-1.3c+

plantuml's People

Contributors

geronymos avatar hajimemat avatar jeff-tian avatar jouyouyun avatar koppor avatar nwest09 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

plantuml's Issues

Introduce caching

The minted package calculates a hash on the input and uses cashed results in the case of a match. This speeds up compilation.

Add UTF-8-Support

Can you add UTF-8-Support in the lua-File?

You have to add the parameter -charset UTF-8 in the java-call in plantuml.lua:

local cmd = "java -jar " .. plantUmlJar .. " -charset UTF-8 -t"

I don't know, if you have to check at first, that the LaTeX-Source is in UTF-8-Mode?

Thank you very much.

Support using a PlantUML server

It would be nice if was possible to use a PlantUML Server to parse the UML stuff instead of installing it locally with all its dependencies (first integration in this way seen at GitLab).

This would make it very easy to use it in combination with a CI server, regardless of the operating system of the development machine and the build server.

SVG example does not work with newer inkscape versions

Hi,

I just figured out, that the svg example does no work with inkscape 1.1 as inkscape has changed its CLI parameters.

I changed the \epstopdfDeclareGraphicsRule to the following to make it work again:

\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{
  inkscape #1 --export-text-to-path --export-filename=\OutputFile
}

Maybe this should be mentioned/updated in the readme.md :)

I also added the --export-text-to-path parameter as the rending with text as text looked really broken - only lines und shapes were fine the text was totally messed up in the PDF generated by inkscape.

Best regards and thanks a lot for your work!

Plantuml Latex broken

Plantuml switched to generating latex with the propper .tex extension instead of .latex as used in this package
see this pr

as a result of this, this latex package is now broken

Different margins for text located in boxes using PlantUML LaTeX-package

Hello,

I want to use the PlantUML in LaTeX and get different margins on the left and right side of a text when it is located inside a box. My output generated with the PlantUML LaTeX package looks like:

Latex-Issue

If I generate the mindmap using the standalone-jar everything works fine.

My Code in LaTeX is:

\begin{plantuml}
@startmindmap
title Übersicht über Methoden der Wirkungsgradbestimmung/ Leistungsmessung

* Wirkungsgradbestimmung/\n Leistungsmessung
** mittels Messung
*** direkte Messung
*** indirekte Messung
*** kalorimetrische Messung
****_ A
*****_ 1
*****_ 2
****_ B

@endmindmap
\end{plantuml}

I have to mention, that I'm using LuaLaTeX to generate the helper files like 'Thesis-plantuml.txt' or 'Thesis-plantuml.latex', but in the end for the final build I use pdfLaTeX.

The command-line commands for building my thesis looks similar like:

%LUALATEX% -shell-escape -interaction=nonstopmode %MYFILE% > NUL:
.
.
.
%PDFLATEX% -shell-escape %MYFILE% > NUL:

Maybe it's an issue with the conversion from PlantUML to Tikz?

Thanks in advance for any reply/help!

handle tex filename with spaces

  1. create a *.tex file with spaces in the filename, such as file name.tex
  2. add \usepackage{plantuml} and \begin{plantuml} block
  3. call lualatex --shell-escape -file-line-error -synctex=1 -interaction=nonstopmode -file-line-error -recorder "/Users/naugler/software/docs/file name.tex"
  4. logs show Source "file name"-plantuml.txt does not exist.

Error during latex code generation

I am trying to run the minimal working example form the repo, I get no errors in the compilation process, but the PDF contains only the line Error during latex code generation. The paths seem to be correctly set, but is there a way to check or debug this?
plant.log

Fails when multiple diagrams are present

\documentclass{scrartcl}
\usepackage{graphics}
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{
  inkscape -z --file=#1 --export-pdf=\OutputFile
}
\usepackage[output=svg]{plantuml}
\begin{document}
\begin{plantuml}
@startuml
class Car

Driver - Car : drives >
Car *- Wheel : have 4 >
Car -- Person : < owns
@enduml
\end{plantuml}

\begin{plantuml}
@startuml
class Bus
@enduml
\end{plantuml}

\end{document}

Produces wrong output as soon as 2 diagrams exist. The output file name seems to be always the same. Thus, the second diagram overwrites the first one.

How to add a # sign in a diagram

I tried to add a # for protected fields, but the compilation fails. I know that the # is a special character in latex, so I tried to escape it with a \ but it didn't work

Unable to access jarfile when PLANTUML_JAR contains spaces on Windows

If PLANTUML_JAR contains a path with spaces in it, compiling results in an error (Example path: C:\Program Files (x86)\PlantUML\plantuml.jar):

Error: Unable to access jarfile C:\Program

I tried it out running the java cmd on the command line, same result there. If you put quotes around the environment variable everything works fine.

How to add a \caption properly?

Hello,
I wanted to add a caption to my plantuml. I tried to solve this with wrapping inside a figure.
But now I have to problem that the plantuml floats sometimes in really bad ways, even sometimes it places itself between other lstlistings :/.

Is there a way to do better?

\begin{figure}[h]
	\begin{plantuml}
	
	@startuml
	Alice -> Bob: Authentication Request
	Bob --> Alice: Authentication Response

	Alice -> Bob: Another authentication Request
	Alice <-- Bob: another authentication Response
	@enduml
	
	\end{plantuml}
	\caption{my caption}
	\label{my label}
\end{figure}

component diagram support

Thank you for making this amazing package. With a component diagram I made the connection "component --( interface". It worked in plantUML oudside of latex, but with the latex plugin I got the following error.

An error has occured : java.lang.UnsupportedOperationException
I’m both. I’m a celebrity in an emergency.
Diagram size: 29 lines / 533 characters.
PlantUML (1.2019.00) cannot parse result from dot/GraphViz.
Please go to http://plantuml.com/graphviz-dot to check your GraphViz version.
Java Runtime: Java(TM) SE Runtime Environment
JVM: Java HotSpot(TM) 64-Bit Server VM
Java Version: 1.8.0_201-b09
Operating System: Windows 7
OS Version: 6.1
Default Encoding: Cp1252
Language: nl
Country: NL
Machine: Kantoor-2-15
PLANTUML_LIMIT_SIZE: 4096
Processors: 4
Max Memory: 1,884,815,360
Total Memory: 231,211,008
Free Memory: 167,578,752
Used Memory: 63,632,256
Thread Active Count: 1
This may be caused by :

  • a bug in PlantUML
  • a problem in GraphViz
    You should send this diagram and this image to [email protected] or
    post to http://plantuml.com/qa to solve this issue.
    You can try to turn arround this issue by simplifing your diagram.
    java.lang.UnsupportedOperationException
    net.sourceforge.plantuml.ugraphic.tikz.DriverEllipseTikz.draw(DriverEllipseTikz.java:61)
    net.sourceforge.plantuml.ugraphic.tikz.DriverEllipseTikz.draw(DriverEllipseTikz.java:44)
    net.sourceforge.plantuml.ugraphic.AbstractUGraphic.draw(AbstractUGraphic.java:89)
    net.sourceforge.plantuml.svek.extremity.ExtremityParenthesis.drawU(ExtremityParenthesis.java:67)
    net.sourceforge.plantuml.svek.Line.drawRainbow(Line.java:758)
    net.sourceforge.plantuml.svek.Line.drawU(Line.java:704)
    net.sourceforge.plantuml.svek.SvekResult.drawU(SvekResult.java:92)
    net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageInternal(ImageBuilder.java:254)
    net.sourceforge.plantuml.ugraphic.ImageBuilder.writeImageTOBEMOVED(ImageBuilder.java:178)
    net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.createFileInternal(CucaDiagramFileMakerSvek.java:127)
    net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.createFile(CucaDiagramFileMakerSvek.java:71)
    net.sourceforge.plantuml.cucadiagram.CucaDiagram.exportDiagramInternal(CucaDiagram.java:379)
    net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:238)
    net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:135)
    net.sourceforge.plantuml.PSystemUtils.exportDiagramsCuca(PSystemUtils.java:236)
    net.sourceforge.plantuml.PSystemUtils.exportDiagrams(PSystemUtils.java:92)
    net.sourceforge.plantuml.SourceFileReaderAbstract.getGeneratedImages(SourceFileReaderAbstract.java:157)
    net.sourceforge.plantuml.Run.manageFileInternal(Run.java:508)
    net.sourceforge.plantuml.Run.processArgs(Run.java:403)
    net.sourceforge.plantuml.Run.manageAllFiles(Run.java:372)
    net.sourceforge.plantuml.Run.main(Run.java:188)
    Diagram source: (Use http://zxing.org/w/decode.jspx to decode the qrcode)
    null
    null

Support for the --( relation would very much be appreciated.

Can't use SVG with multiple diagramms

If I use svg as output I can not include more then one diagram.
Example:

\documentclass{scrartcl}

\usepackage{graphics}

% Enables inclusion of SVG graphics - 1:1 approach
% This is NOT the approach of https://ctan.org/pkg/svg-inkscape
% which allows text in SVG to be typeset using LaTeX.
% We just include the SVG as is.
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{%
  inkscape -z --file=#1 --export-pdf=\OutputFile
}

\usepackage[output=svg]{plantuml}

\begin{document}
\begin{plantuml}
	@startuml
	class Car
	
	Driver - Car : drives >
	Car *- Wheel : have 4 >
	Car -- Person : < owns
	@enduml
\end{plantuml}

\begin{plantuml}
	@startuml
	class B
	
	A - B : drives >
	B *- D : have 4 >
	B -- C : < owns
	@enduml
\end{plantuml}

\end{document}

Support pdflatex

Ideas:

  1. Use pythontex and the remote PlantUML server using Python's plantuml.

  2. Build on checklistings, which generates a checklistings.sh file for the compiler. Drawback: Users have to call an external tool.

  3. Use pythontex and its bash functionality to locally execute PlantUML.

  4. Use bashful to execute bash scripts.

The package download can download files, but this does not help much here as we can also download plantuml within a bash script.

Output directory

When calling luatex with an -output-directory plantuml cant find the generated files.

lualatex -shell-escape -output-directory=./out/

Any fix for this?

Overleaf

According to user Zarylo on Stackoverflow:

overleaf apparently supports plantuml by running a plantuml server for diagram generation, meaning you only need to set it to use the lualatex engine in the project settings.

Does anyone have any sort of reference for this? I can't seem to get this package to work in Overleaf:

image

When creating a blank output-plantuml.tex file, the PDF compiles but no figure gets generated. I have the compiler set to LuaLaTeX.

Global preamble

The default PlantUML style is colorful, but not good for printouts. Currently, the style has to be put at each plantuml environment. There should be a global configuration put just before the code in the plantuml environment.

Example preamble:

'skinparam monochrome true
'Chooses LightGray as background color
'We're better off with manual setting

skinparam class {
	BackgroundColor White
	ArrowColor Black
	BorderColor Black
	LegendBackgroundColor White
}

skinparam stereotypeCBackgroundColor LightGray

skinparam noteBackgroundColor White
skinparam noteBorderColor Black

'required for SVG
skinparam defaultFontName sans-serif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.