Typst

Typst is a typesetting system, so an alternative to TeX, LaTeX, &c. It's free and open source software (FOSS), but if you visit typst.app it looks like you're meant to sign up for something then use it on the web. But you can download and install it locally, just like any good FOSS product.

If you're fortunate enough to click on the github link, you'll find instructions for installing it locally several different ways. But even that steers you back to the web app. Similarly, if you find your way to the tutorial, it too mentions working locally, but encourages you to use the web app. It's a shame because it works really well locally.

With Rust installed, you can install Typst locally with

cargo install --locked typst-cli

That installs a typst executable in the usual Cargo directory.

$ which typst
/home/tim/.cargo/bin/typst

Now if you create a hello.typ file with your favorite editor

= Introduction
In this report, we will explore the
various factors that influence _fluid
dynamics_ in glaciers and how they
contribute to the formation and
behaviour of these natural structures.

you can compile it with

typst compile hello.typ

This creates hello.pdf, which you can look at with your favorite pdf viewer.

evince hello.pdf

In Emacs 29.1 or newer, there is a typst-ts-mode which we can install with

M-x package-install RET typst-ts-mode RET

This requires a tree-sitter grammar which we can install with

M-x treesit-install-language-grammar RET typst RET

This installs a binary called tinymist, which serves as the language server. It is also a previewer, so we can link to a place in our path

ln -s ~/.emacs.d/.cache/lsp/tinymist/tinymist ~/.local/bin/tinymist

Then we can start a previewer in our default browser with

tinymist preview hello.typ

So I've been configuring Emacs for Typst this way

(use-package typst-ts-mode
  :ensure t
  :hook (typst-ts-mode . eglot-ensure)
  :hook (typst-ts-mode . auto-fill-mode)
  :config
  (add-to-list 'treesit-language-source-alist
               '(typst "https://github.com/uben0/tree-sitter-typst")))

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs '(typst-ts-mode "tinymist")))

and previewing in the browser. I guess I could set it up to preview inside Emacs, but so far I've been happy with this solution.

screenshot with Emacs opened on the Typst file and Firefox opened on tinymist preview

Sylvan Franklin made a nice video introduction to Typst recently. He is working locally in vi, but he doesn't say how he set it up.