TikZ/PGFplots etx

2015-03-02 — 2026-05-06

Wherein TikZ Is Compiled to WebAssembly and Rendered in the Browser Without a LaTeX Installation, Its Portability Across Quarto, Obsidian, and Other Environments Is Examined, and Various GUI Frontends Are Noted.

communicating
computers are awful
dataviz
faster pussycat
LaTeX
photon choreography
plain text
typography
UI
workflow
Figure 1

The classic type-your-diagram-then-work-out-what-went-wrong option for plotting. If I am constructing a well-understood type of diagram (e.g. a PGM) then this is good. If I am doing something unusual, it can become tedious. However, ChatGPT is very good at writing TikZ, and that is what I usually use.

The main strength of TikZ compared to other text-to-diagram tools is that it has flexible ways of declaring layouts. Alternative tools prefer automatic layouts, which sounds like a good idea, but empirically, it has never actually been what I want when I’m trying to draw a diagram that uses spatial information to convey things.

The original flavour, pstricks/TikZ, is based on PostScript and has compatibility problems with modern toolchains. Modern projects seem to prefer the more compatible (less powerful?) PGF/TikZ.

latexdraw is a Java pstricks GUI. Might be good, but I couldn’t install it.

TikZiT looks like a reasonably good alternative GUI (HT Luis Riera Garcia for showing me this)

a super simple GUI editor for graphs and string diagrams. Its native file format is a subset of PGF/TikZ, which means TikZiT files can be included directly in papers typeset using LaTeX.

Agustinus Kristiadi, in The Last Mile of Creating Publication-Ready Plots, introduces texworld/tikZplotlib, a matplotlib backend.

The Overleaf tutorial, LaTeX Graphics using TikZ, is probably the best one.

I am currently rendering TikZ in quarto using an extension I wrote: danmackinlay/quarto\_tikz. There is also pandoc-ext/diagram, which has more features but is a bit broken on recent Quarto versions and has more opaque error messages. I prefer my own extension because I like simple things.

1 In the browser

drgrice1/tikzjax is TikZ compiled to WebAssembly, i.e. the browser execution engine for Fancy Code: it renders TikZ to SVG in the reader’s browser, with no pdflatex and no LaTeX install required of anyone. The price is a WASM bundle on the page, which is a few megabytes. One downstream consumer is artisticat1/obsidian-tikzjax, which wraps the engine as an Obsidian plugin — TikZ as a first-class block in the most popular markdown PKM app.

The implication is that TikZ is no longer a LaTeX-only diagram language. The same source compiles in Quarto via my quarto_tikz, in Obsidian via the plugin, and anywhere else that hosts the WASM engine. So my notes on this site turn out to be accidentally portable.1.

A quarto_tikz-shaped extension that targets tikzjax for HTML output instead of shelling out to pdflatex would trade a LaTeX install plus compile time for a WASM bundle on the page, so I vibe coded one. Let us see if it works.

2 Incoming

3 References

Kottwitz. 2023. LaTeX Graphics with TikZ: A practitioner’s guide to drawing 2D and 3D images, diagrams, charts, and plots.

Footnotes

  1. I think we are restricted to self-contained notes, i.e. not importing external \input↩︎