[Tex/LaTex] How to set XeLaTeX as the default engine

latexmktexlivevimxetex

I use Neovim with the vimtex plugin and latexmk but I want to make it use XeLaTeX by default instead of PDFLaTeX because I have to use fontspec quite often for my college papers. I use TeX Live.

Best Answer

The variable $pdf_mode is responsible for the engine used to generate pdfs. You have to set $pdf_mode to 5 if you want to use XeLaTeX. You can do that by adding the following line to your configuration file (i.e. $HOME/.latexmkrc):

$pdf_mode = 5; 

Possible values for $pdf_mode are:

0 = no pdf
1 = pdflatex
2 = pdf from ps 
3 = pdf from dvi 
4 = lualatex
5 = xelatex

This is well documented in the manual, which you can access either with man latexmk or, with TeX Live, texdoc latexmk.