Can latexmk generate a DVI file with lualatex or an XDV file with xelatex without generating a PDF

dvilatexmkluatexxetex

Background: I am the developer of IguanaTex, a PowerPoint add-in to insert LaTeX displays in Powerpoint. I would like to let my users generate SVG files using dvisvgm via either a DVI file or an XDV file, because PDF can lead to issues in the generated SVG file. Some of my users want to use lualatex or xelatex, and some of them also want to rely on latexmk in order to produce correct cross-references.

latexmk supports xelatex and lualatex, but the main target output is PDF, and I could not find a way to only output either a DVI or an XDV file.

For xelatex, I can use latexmk -pdfxe -pdfxelatex="xelatex --shell-escape %O %S" foo.tex to generate both XDV and PDF.

For lualatex, I can use latexmk -pdflua -lualatex="lualatex --shell-escape -output-format dvi %O %S" -e "$dvipdf='dvipdfmx %O %S'" foo.tex to generate both a DVI and a PDF.

In both cases, I don't need the final DVI to PDF conversion step and would like to skip it for efficiency. Is there a way to do this?

Best Answer

Latex maintainer here. You can get latexmk to use lualatex to produce a dvi file (with no by the following

latexmk -dvi -pdf- -latex="dvilualatex --shell-escape %O %S" foo.tex

That is you tell latex to make a dvi file, but to use dvilualatex where by default it would use latex.

With the present version of latexmk, there's no simple way of using it to produce an xdv file without also making a pdf file.

I'll take this question as a feature request for options to achieve what is asked for, perhaps -dvilua and -xdv.

Postscript (23 Apr. 2022): I've added these features to the development version of latexmk, and they will appear in the next release.