Wednesday, September 23, 2026

More Typsting

It's been a month since I first tried out Typst, and I have quickly fallen in love. I first used it to write up the syllabi for my classes at the beginning of the semester. They were functional, and looked all right, though were a few things I wasn't able to figure out in the limited time I had. Then I found myself going back and fixing those things, adding new features, turning common features into a template to apply, and occasionally sometimes often using it as a way to procrastinate from other important work (like grading lab reports).

Last week I decided to try using it to write out the problems and solutions from my recitation session (for the calculus-based second year electricity and magnetism course PHYS 272). I'd been providing students with photos of my hand-written notes, but those are always terse and limited to what I need as I'm not overfond of writing. With Typst, I can not only recreate them, but trivially expand upon them and provide context for why I'm taking the steps I am towards the solution.

In practice there was a consideration which kept me from doing this sooner, and that's the presence of diagrams. Much of the problem-solving in E&M involves little pictures, diagrams of the simplified problems we're tackling. They aren't usually very complex, but they're a step beyond the pure text and math I was already getting used to writing in Typst.

Fortunately, Typst has a solution for this: the CetZ package, which allows drawing figures and diagrams within a document. \(\LaTeX\) has something similar in the form of the TikZ package (which inspired CetZ), but while I've been aware of TikZ's existence for quite a few years now I've never had enough motivation (or need) to get around to learning it. With how much fun I was having with Typst, I decided that maybe learning CetZ on top would be beneficial.

And while there have been some difficulties along the way, I've been having a lot of fun with it as well! CetZ is, by its own admission, not as mature as TikZ, but it's already plenty powerful for what I need. Within a few hours of reading its tutorial for the first time Wednesday morning I was making simple diagrams, and I've already improved quite a bit in the intervening time. With the addition of CetZ-Plot, a package that adds plotting capabilities to CetZ, I was even able to get the example shown below under “Electric field of a uniformly charged insulating sphere,” where I could plot the actual \(1/r^2\) fall-off of an inverse-square quantity by defining a function and plotting it.

I'm sure everything I've done with CetZ can be done with TikZ as well, but I was seriously impressed at how easy Typst makes things and how quickly I was able to pick it up. Typst's incremental compilation also means that changes to my diagrams are rendered instantly whenever I change anything, which makes it very easy to iterate and figure out why something isn't working like I think. Thankfully, I now have a reason to keep using it each week as I type up my notes! I even feel something of a desire to make a presentation on it to share with people, but we'll see if that goes anywhere*. A hui hou!

*I am teaching a writing intensive class, and it could be beneficial for students to be aware of…

Tuesday, September 8, 2026

Trying Typst for the first time

I've been meaning to check out Typst for over a year now. The premise was intriguing: what if we rewrote \(\TeX\) (and \(\LaTeX\)) from the ground up, discarding the parts that made sense fifty years ago and taking everything we've learned in the meantime to make a simpler, clearer markup language? (And also wrote it in Rust for blazing speed.)

I've mentioned \(\LaTeX\) and my love for it many times on this blog. I think I was first introduced to it during the spring semester of 2010, and my immediate thought was: where has this been all my life? \(\LaTeX\) is a markup language (built as an extension of the earlier \(\TeX\)) where documents written in it are compiled to output a nicely typeset version (usually in a format like .pdf or .ps). One of its big selling points is its ability to handle complex mathematics; for scientific writing in particular, which may need to include complex equations with highly specific formatting, it's a lifesaver. I've got a Javascript library called MathJax on this blog which lets me use (some) \(\LaTeX\) formatting to display mathematical output such as:

\[\text{Coulomb's Law: } F=k\frac{q_1 q_2}{r^2}\hat{r}\text{ where the Coulomb constant } k=8.988\times10^9\frac{\text{N}\cdot\text{m}^2}{\text{C}^2}.\]

I was initially drawn to \(\LaTeX\) for the beauty of its output. It was also practical: you can write pretty much any kind of document in \(\LaTeX\), and most scientific journals allow (or require) manuscripts to be submitted in it. I wrote my thesis in it, then turned it into two papers for publication.

At the same time, \(\LaTeX\) is not without its weaknesses. The underlying language \(\TeX\) is both very powerful and very complex (\(\LaTeX\) is essentially an addon for \(\TeX\) to make it easier to use), has a famously steep learning curve, doesn't natively handle UTF-8 characters, and even after years of using \(\LaTeX\) I occasionally run into bizarre issues. Perhaps the strangest was discovering that a hyperlink which spanned a page break in my thesis caused the whole document to fail with a very obscure error message – one I actually never found a real fix for despite much searching. The only advice I could find which worked was to adjust the length of the text before the hyperlink such that it no longer crossed two pages!

This is not to disparage \(\LaTeX\) – it's still worth knowing, I think, has been immensely useful for many people around the world, and it still feels a little magical to watch it take a series of abstruse text and turn it into something beautifully formatted. However, I'm cognizant of its flaws, and open to new experiences.

Enter Typst.

There's something of a pattern in software development, where after developing a piece of complex software, sometimes the best way to improve is to start over from scratch using the lessons learned rather than try to continue patching and editing it. Typst is essentially that rewrite for \(\LaTeX\), taking lessons learned from the last forty years and improving upon it (at least in theory).

Over the summer I read through the Typst tutorial, though Hurricane Lala knocking out power for two days the week before the semester started put a crimp in my plans to try writing my syllabi with it. A practical demonstration of Typst is that I sat down Sunday afternoon the day before I was due to begin teaching and attempted to write a syllabus in it (based on an existing \(\LaTeX\) template I had), and within an hour or two I'd created something which mimicked ~95% of the original's look while requiring much less text to pull off. I was seriously impressed, and then hooked.

It's a little hard to show off what Typst can do, since by design it's often used to mimic the look of \(\LaTeX\) documents. What I can say, however, is that it's much easier to use. This morning in some free time I followed the tutorial instruction to turn my syllabi into a template for future syllabi to use, something I've never even attempted in \(\LaTeX\).

It's also a real joy to use due to lightning-fast compilation. With \(\LaTeX\) you have to run a compiling command, which even for relatively short documents often takes a few seconds. Typst compiles incredibly quickly due to an incremental compilation system, allowing you to see the output of what you're typing in basically real time. And coming back to writing \(\LaTeX\) for this post, I find myself appreciating that all the more; it's amazing what a shorter feedback loops does, allowing you to more easily experiment and try things and see the result immediately.

I could wax lyrical about other features of Typst*, but this post is getting long and I have a feeling I'll be talking about it more in the future. I find myself drawn back to it, wanting to experiment and see what else I can get it to do. And that's perhaps the greatest endorsement I can give Typst: using it is fun. I'm reminded of the heady days when I first discovered \(\LaTeX\), and I can hardly wait to write more in Typst and see what interesting and beautiful things I can create with it. Hopefully I can show some off in the future when I've learned more! A hui hou!

*Typst's syntax is generally lighter and simpler than \(\LaTeX\)'s, its error messages when something is broken are extremely helpful in pointing you to the problem, it has a powerful and flexible CSS-like functionality built-in which makes it a snap to style elements, etc.