My workflow with latexmk


When writing LaTeX documents I use latexmk to handle the compilation. Once upon I time I used LaTeX regularly and all knew all the commands. Recently I wrote a LaTeX document for the first time in a long time and had forgotten the way I like to use latexmk. This post is to save myself from rediscovering my setup in the future.

I have two termial windows open. In one window I run the following command

latexmk -pdf -pvc --halt-on-error document.tex

Alternatively, I use the newer xelatex or LuaTeX by replacing -pdf with -xelatex or -lualatex.

The brilliant -pvc option is short for “preview continually” and recompiles every time there is a change in the document or one of its dependencies. This option prevents the situation where I write a ton of complex formulae after a successful compilation only to discover that there are lots of LaTeX errors to be resolved.

The option --halt-on-error is an option for pdflatex that stops the program if there is an error instead of asking for a resolution during the compilation. This is really a key thing for me as the compilation would otherwise require a great deal of attention to keep running.

In the other windows I run tmux with Vim for writing and whatever else I do that is not related to latexmk. It is tempting to also run latexmk in a tmux window, but tmux is not very responsive during LaTeX’s compilations.

>> Home