I am using latexmk as the pdf-engine for pandoc, that is, I use the command

pandoc --pdf-engine=latexmk --pdf-engine-opt=-emulate-aux-dir --pdf-engine-opt=-aux-directory=aux \
test.md -o test.pdf

to compile test.md into a test.pdf file.

When doing so, latexmk issues a warning message:

Latexmk: In reading rule 'pdflatex' in 'aux/input.fdb_latexmk',
  destination has different name than configured...

Using similar commands, I sometimes get a fairly similar complain:

Latexmk: In reading rule 'xdvipdfmx' in 'aux/input.fdb_latexmk',
  name of destination file is not current one; I'll flag rule as out of date.

I am guessing that pandoc does some renaming behind the scene (all the files in the aux folder are input.tex, .log, etc.) and that latexmk does not like the fact that a command does not comply with the <filename>.tex -> <filename>.pdf usual way of naming things, but I am not completely sure, since, as far as I know, this error message is not documented.

I'm not sure if I should ask john-collins or the pandoc mailing list about it: but can anyone confirm that this error message is not documented, and guess how I should interpret it?

  • 1
    The source of latexmk has the following comment for the warning (line 6062): Deal with possibility that destination in fdb_latexmk has different name than the default one. The only case that concerns us is where the extension is changed (by \pdfoutput, e.g., in tex file). But it is possible out and aux directories have been chosen differently, and the user choice there MUST OVERRIDE the value in the fdb_latexmk file. So it seems that this can be corrected at the Pandoc side by providing some setting to latexmk.
    – Marijn
    Nov 2, 2021 at 7:59
  • Thanks, @Marijn. For my own future reference, the source code is at mirrors.ctan.org/support/latexmk/latexmk.pl.
    – Clément
    Nov 3, 2021 at 16:24
  • 1
    John Collins here. It would probably be best if you contacted me off line at the e-mail in the latexmk documentation. That would make it easier to set up some diagnostic tests in a latexmk configuration file, so that I can see exactly what latexmk thinks is going on. (Unfortunately in the latexmk warnings you quote latexmk doesn't provide all the necessary details that it should.) Nov 4, 2021 at 0:35

2 Answers 2


While trying to understand that bug better I found out the following:

pandoc test.md --pdf-engine=latexmk --pdf-engine-opt=-emulate-aux-dir --pdf-engine-opt=-aux-directory=aux -o test.pdf


Rc files read:
Latexmk: Run number 1 of rule 'pdflatex'
Latexmk: Run number 2 of rule 'pdflatex'


pandoc --pdf-engine=latexmk --pdf-engine-opt=-emulate-aux-dir --pdf-engine-opt=-aux-directory=aux test.md -o test.pdf


Rc files read:
Latexmk: In reading rule 'pdflatex' in 'aux/input.fdb_latexmk',
  destination has different name than configured...
Latexmk: Run number 1 of rule 'pdflatex'

so the order matters: the name of the input file should preced the options when invoking pandoc.


The phenomena reported in the question are a consequence of pandoc's use of a temporary directory for the intermediate files (input.tex and input.pdf). A new temporary directory is used on each run, with a different name. Then the warning message(s) given by latexmk result from the combination of this and the use of latexmk with an auxdir to preserve information between runs. Since latexmk adjusts to the situation on the current run, correct results are obtained, and the warnings can be safely ignored.

However, the warnings do indicate that latexmk detected a potentially anomalous situation that the user may need to know about. In this case, the workflow can be improved to get more advantages from the use of latexmk, without the messages. (In addition, the messages need to be improved, which I've done for the next release of latexmk, probably v. 4.76.)

Detailed diagnosis

Pandoc puts an input.tex file generated from the source file in a temporary directory. It compiles it to an input.pdf file in the same directory, with the use of the --output-directory option to latexmk (or to pdflatex if that is used instead). It then copies/moves the .pdf file to the final destination, and finally removes the temporary directory. The next time pandoc is used, the temporary directory is different. Between runs of latexmk, information about the state of files is preserved in the input.fdb_latexmk file mentioned in the warning messages from latexmk; this include information on the input.pdf file. With the changed name of the temporary directory on the next run, latexmk reports what it sees, since it does not correspond to the situations it usually deals with. It adjusts to the new conditions. The directory part of name of the 'input.tex` file also changes, but that's handled correctly by latexmk's usual method of detecting changes of source files, so it doesn't report that.

Solution 1

Use an output directory by giving pandoc the appropriate option, e.g.,




Then pandoc generates both the intermediate input.tex and input.pdf files in the specified directory, but doesn't delete them at the end of the run. This actually works with both latexmk and pdflatex as the pdf engines used by pandoc.

A small advantage of this is that if the .md source file hasn't changed when you rerun pandoc, latexmk no longer does any run of pdflatex, since the input.tex file hasn't changed in location. The original method always results in at least one run of pdflatex by latexmk.

You could also just use an output directory, without separate use of an aux directory. That is documented in the current pandoc manual.

I tested that this solution does work with at least the current version, 2.16.1 of pandoc.

Solution 2

It is also possible to use pandoc only to generate a (stand-alone) .tex file, and then apply latexmk to that. Under a Unix-like operating system (e.g., Linux, macOS), the following command works, when the source file is trymd.md

pandoc trymd.md -s -o aux/trymd.tex \
&& latexmk -auxdir=aux -outdir=. -emulate-aux-dir -pdf -quiet aux/trymd.tex \
&& rm trymd.fls

(If you use MS-Windows, you will have to use a suitable equivalent, of course.)

Now all the intermediate files are in the aux directory only. They also have the same base name as the .md source file, so applying this method to multiple source files doesn't result in interference between files. (In contrast, leaving all the work to pandoc results in intermediate files with a single base name, input.)

Solution 3 (proposed)

(I haven't implemented this, at least not yet.) It should be possible to configure latexmk to get pandoc to do a conversion from an .md (or other file) to an intermediate .tex file before it runs pdflatex. Then you could just do latexmk file.md, without mentioning pandoc except in a latexmk configuration file.

This is a practical example of a more general situation where a .tex file is not written by the user but is generated programmatically from other source files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .