Latexmk Trick for Typst

This configuration makes a Typst project look like a LaTeX project.
Specifically, you call latexmk and typst will generate main.pdf.

Configuration

latexmkrc:

# See https://mirror.ctan.org/support/latexmk/example_rcfiles/tex4ht-latexmkrc
$dvi_mode = 1;
$pdf_mode = 0;

# Prevent lulatex from producing PDF, and allow to call typst
# To preserve PDF bookmarks and cross-links, we let typst produce main.pdf directly, instead of using LaTeX pdfpages \includepdf
$latex = 'lualatex --output-format=dvi --shell-escape';

main.tex:

\documentclass{article}
\usepackage{shellesc}

\begin{document}
\ShellEscape{typst compile main.typ main.pdf}
If you see this line in the PDF, you should recompile with latexmk. Refer to README.txt for details.
% That line also prevents _No pages of output_, so latexmk will treat the compilation as successful.
\end{document}

README.txt:

# How to compile

tlmgr install scheme-minimal collection-latex luatex latexmk
curl -fsSL https://install.typst.community/install.sh | sh -s 0.15.1

latexmk

Related projects

I guess in 99% cases, you would want one of the following projects instead of the above latexmk configuration…

You can also find more tex🡘typ projects in :triangular_ruler: Math | Best of Typst (TCDM).

1 Like

Haha, that’s so cursed. I assume you had real use for this, otherwise you wouldn’t have though of it. If you don’t mind me asking, since I’m curious- in what scenario did you use this?