Daily-Driving Typst

Published on 3 Jul 2023

I used LaTeX on daily basis to generate reports1 for experiments I completed in the last 2 years of graduate school. The decision to use LaTeX came down to (a) it is plaintext2, (b) free and open source, (c) basically works everywhere. My data analysis stack involves a frequent use of Python data science packages3 with occasional ventures into R4. Each project gets a folder that looks like this:

All raw (tabular) data go into the Data directory and all analysis scripts (typically .py) go into the Pipeline directory. All plots are rendered into the Charts directory. Eventually, all plots are compiled into a PDF, where the plaintext source files live inside the Report Tex directory.

When a plot gets updated, the plaintext source file for the report will only need a recompilation.

I found LaTeX unwieldy to use at my current $WORK5. After all, I customized my LaTeX installation quite extensively6. In the meantime, I tried Quarto and abandoned it because it did not have the same luster as LaTeX. Then came Typst, aiming to compete both against LaTeX and Overleaf. As with any case trying to challenge LaTeX will be met with cynical look, I think Typst might make it.

It runs as a single binary7. As of writing, the whole program is less than 10 mb. This is a huge value proposition for Typst, when compared to the absolute behemoth that is LaTeX8. The syntax and markup do require learning, but it was an easy transition from LaTeX to Typst.

This is my current preamble for my Typst document.

#set page("us-letter", margin: (x: 32pt, y: 32pt), columns: 2)
#set text(font: "Fira Sans", size: 8pt)
#set par(leading: 1em, first-line-indent: 1em)

At the time of writing, this preamble fulfills most of my authoring needs. This is an example of my recent document:

Typst feels ergonomic and a joy to use. The error messages are helpful, which is a massive quality-of-life upgrade compared to LaTeX. Well, good luck thumbing through LaTeX’s copious warning messages on the stdout. I hope Typst will gain widespread adoption in the future.

Some Additional Notes and Codes

X and Y margins at 28pt, especially on the sides, are just enough to avoid hole-puncher. A value of 32pt might be better.

Variable binding with let keyword, to which I use these to bind the commonly-used named colors for styling my documents.

// variable binding ------------------------------------------------------------
#let orangered = "#ff4500"
#let forestgreen = "#228b22"
#let midnightblue = "#191970"
#let blueviolet = "#8a2be2"

To apply color, write #text(fill: rgb(orangered))[text here] syntax. Or even better, we can create a new function with the let keyword.

#let t_ored(body, fill: rgb("#ff4500")) = {
	set text(fill)
	[#body]}

#let t_fgreen(body, fill: rgb("#228b22")) = {
	set text(fill)
	[#body]}

#let t_mblue(body, fill: rgb("#191970")) = {
	set text(fill)
	[#body]}

#let t_bviolet(body, fill: rgb("#8a2be2")) = {
	set text(fill)
	[#body]}

Now I can call it by writing t_ored[text here] to color “text here” in orange red.


  1. LaTeX is overkill in this regard. But as always, I overengineer solutions to simple problems. Normally, a PPTX PowerPoint file with all the figures. This is what most people do. However, I find joy in writing prose. Writing is thinking. Writing is an instrument for thinking. A clear writing is a clear thinking. Writing in DOCX Word document, to me, sometimes can devolve into a mess because of my constant fight with the formatting. A plaintext file removes that. ↩︎

  2. Which means it is git-able. Markdown file is also git-able, but I find Markdown format being too simple for my scientific needs. ↩︎

  3. Jupyter, Pandas, NumPy, Matplotlib, Seaborn, Scikit-Learn, etc. ↩︎

  4. Mostly for emmeans and lme4. ↩︎

  5. The computer is locked-down (as with most organization) and installing new software involves sending a ticket. ↩︎

  6. See this Gist for my aizancommons.sty file. ↩︎

  7. Drop it anywhere or in $PATH! Cannot get any easier than that! Worth mentioning that this tool is written in Rust. From my experience using tools written in Rust, they mostly have stellar qualities. ↩︎

  8. Installing LaTeX is not trivial. Linux users tend to download LaTeX packages from upstream package repository. There are 5 options: texlive-base, texlive-base-recommended, texlive, texlive-latex-extra, and texlive-full. The full version comes at 5GB installation size. By installing it through the distro’s repository, users can’t use texliveonfly to downloading missing packages, or even the tlmgr TeX Live package manager tool. In other words, customizing a LaTeX installation can get tricky. ↩︎