I usually want latexmk to use pdflatex and synctex by default, so I have the following in my RC file and everything works hunky-dory:
$pdf_mode = 1; $pdflatex = 'pdflatex -interaction=nonstopmode -synctex=1 %O %S';
However, some documents I want to compile into PDFs using xelatex and synctex. How can I change my RC file so that latexmk still uses pdflatex and synctex by default, but if I pass a single command-line option, it will instead use xelatex and synctex?
I tried (among many other things) the following RC file:
$pdf_mode = 1; $pdflatex = 'pdflatex -interaction=nonstopmode -synctex=1 %O %S'; $xelatex = 'xelatex -interaction=nonstopmode -synctex=1 %O %S';
With this file, invoking
latexmk without arguments still works as expected, but running
latexmk -xelatex or
latexmk -pdfxe throws an error message:
Latexmk: Log file says output to 'foo.pdf' Latexmk: ===For rule 'xelatex', actual output 'foo.pdf' ======appears not to match expected output 'foo.xdv' Failure to make 'foo.xdv' Latexmk: Errors, so I did not complete making targets Collected error summary (may duplicate other messages): xelatex: failed to create output file Latexmk: Use the -f option to force complete processing, unless error was exceeding maximum runs of latex/pdflatex.
There is a previous similar thread on this subject but the solution given there works only for older versions of latexmk. According to a comment by the author, the behaviour of the program has since changed, and latexmk should now "do what you want", though I haven't been able to figure it out.