#+TITLE: Managing Rendering of LaTeX
#+DATE: 2022-10-25
#+FILETAGS: programming

Previously I've used =pdflatex= to render my LaTeX documents, but I've just come across =latexmk=, which provides much more powerful options. Here's a list of the commands I make use of, taken from [[https://mg.readthedocs.io/latexmk.html][this guide]] by Matthias Geier (mgeier).

- =latexmk -pdf [file]= Generate a PDF file from a TeX file. The =-pdf= option prevents the additional generation of [[https://en.wikipedia.org/wiki/Device_independent_file_format][DVI files]], the machine-readable version of TeX. Omitting the file name will generate all of the files in the current directory.
- =latexmk -c [file]= Delete all extra temporary files created in the rendering process.
- =latexmk -C [file]= Delete all generated files, only leaving the original TeX files. (Clean directory.)
- =latexmk -pvc <file>= (File parameter only optional if there is only one TeX file in the directory.) Open up a previewer that automatically refreshes as you are editing your file! Previously, I was using the [[https://github.com/xuhdev/vim-latex-live-preview#usage][xuhdev/vim-latex-live-preview]] extension for Vim using the =:LLPStartPreview= command, but it was randomly =Failed to compile= errors, so it made debugging your markup difficult. By default (at least on my system), =-pvc= opens up the xdvik previewer. You can change this by [[https://mg.readthedocs.io/latexmk.html#configuration-files][updating =~/.latexmkrc=]].

Also a side note, when writing this up I came across [[http://docopt.org/][docopt]], a standard for writing CLI documentation. I had a general idea of the syntax already from seeing it used all over the place, but knowing that there's a standardized spec to refer to is nice. For example, I didn't realize until now that square brackets =[]= are used when arguments are optional, rather than the standard =<>=. The more you know.
