# Document compiles with pdfLaTeX, LuaLaTeX, and XeLaTeX, but not with Latexmk

Background

My computer OS had to be reinstalled recently, thus wiping out my LaTeX installation. Before this time, my document was compiling successfully using Latexmk. I have a complex document I am attempting to compile (glossary, TOC, references, code listings, etc.), and I've had trouble getting it to compile with my newly setup environment.

Troubleshooting Steps

I created a new, minimal document so that I could add packages back one at a time to see what was causing the break, however, Latexmk couldn't even compile this:

\documentclass{article}
\begin{document}
test
\end{document}


All three of pdfLaTeX, LuaLaTeX, and XeLaTeX compile the document without any problems, but Latexmk gives me this error:

Latexmk: Log file says output to 'out/test.pdf'
Latexmk: ===For rule 'latex', the extensions differ between the
actual output file 'out/test.pdf',
and the expected output 'out/test.dvi'.
I could not accommodate the changed output extension
(either because the configuration does not allow it
or because there is a conflict with requested filetypes).
Failure to make 'out/test.dvi'
Collected error summary (may duplicate other messages):
latex: failed to create output file
----------------------
This message may duplicate earlier message.
Latexmk: Failure in processing file 'test.tex':
Could not handle change of output extension
----------------------
Latexmk: Examining 'out/test.log'
=== TeX engine is 'pdfTeX'
Latexmk: Errors, in force_mode: so I tried finishing targets

Process finished with exit code 12


Further Steps Taken

• I assumed at this point that it might be a file ownership issue, but I've confirmed that my user account has ownership of the out directory, thus it should be writable by Latexmk; and it does, indeed, create and populate the directory if it doesn't already exist
• I tried running Latexmk from the command line instead of from the IDE using the following command:
latexmk -f --shell-escape --MSWinBackSlash --interaction=nonstopmode --output-directory=out

This works for the aforementioned minimal file.
• I confirmed that "PDF" is set as the output format option in the TeXiFy IDEA run configuration

My Platform

I am utilizing the following for writing LaTeX documents:

• Microsoft Windows 10
• JetBrains IntelliJ IDEA (the LaTeX document lives alongside Java source code)
• TeXiFy IDEA (plugin for IntelliJ IDEA for working with LaTeX source files)
• MikTeX

After testing the "Output Format" options of "Default", "PDF", and "DVI", and testing those both with and without the -pdf custom compiler argument, I have determined the TeXiFy IDEA plugin is inserting the command line option -output-format=pdf when the PDF option is set, -output-format=dvi when the DVI option is set, and removing the -output-format custom compiler argument altogether when the Default option is set. However, manually adding -pdf to the custom compiler arguments fixes the issue, regardless of the setting of the Output Format field.
After reading the documentation for Latexmk, I have found that there is no -output-format option for that program; this is, instead, an option of pdfLaTeX. Thus, the issue is either with the current version of the TeXiFy IDEA plugin or with the current version of Latexmk. I suspect it is the former, as Latexmk is supposed to pass arguments to the underlying compiler. I have created a bug report on the TeXiFy IDEA plugin's Github repository, and this issue will hopefully be resolved in a future release. Until then, the fix is to manually add -pdf to the custom compiler arguments field.
• Actually this is also a small bug in latexmk. Latexmk recognizes that the -output-format is an option for some of latex, pdflatex, etc and passes it to them, but it fails that its workflow can then be messed up. I'll need to give latexmk better behavior, perhaps merely giving an error when the option is detected, with a suitable message. Dec 29, 2020 at 14:50