Skip to content

Instantly share code, notes, and snippets.

@rajayonin
Last active December 5, 2025 09:12
Show Gist options
  • Select an option

  • Save rajayonin/642d1d8d1e3fdff2b83af97f46d99564 to your computer and use it in GitHub Desktop.

Select an option

Save rajayonin/642d1d8d1e3fdff2b83af97f46d99564 to your computer and use it in GitHub Desktop.
How to insert PlantUML into LaTeX

Requirements

LaTeX

We'll make use of the plantuml package:

\documentclass{...}

\usepackage{plantuml}

\begin{document}
  \begin{plantuml}
    @startuml
    Alice -> Bob: Hello
    Alice <- Bob: Hi!
    @enduml
  \end{plantuml}
\end{document}

Compilation

Requires:

  • Compiling with LuaLaTeX
  • Setting --shell-escape to allow executing PlantUML
  • Setting the PLANTUML_JAR enviroment variable to the path to plantuml.jar

Important

Do not set the --output-directory/-outdir parameter, it breaks PlantUML.

To simplify compilation, you can use latexmk with the provided .latexmkrc configuration file:

$pdf_mode = 4;  # export to PDF
$lualatex = 'lualatex --file-line-error %O %S';  # use LuaLaTeX

# set shell-escape
set_tex_cmds('--shell-escape -interaction=nonstopmode %O %S');

# $out_dir = 'build';  # for some FUCKING reason, this breaks PlantUML

# setup PlantUML
$ENV{PLANTUML_JAR} = 'plantuml.jar';

# cleanup files
$clean_ext .= '%R-plantuml.tex %R-plantuml.latex %R-plantuml.txt aux bbl pytxcode svg-inkscape';
$clean_full_ext = 'build';

Therefore, compile with:

latexmk <whatever>.tex

Folder structure

./
├─ plantuml.jar
├─ <whatever>.tex
├─ .latexmkrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment