The general problem seems to be that latexmk does not seem to work together with graphicx' \graphicspath directive.

I have the following directory structure:

├── working.tex
├── non-working.tex
├── latexmk
└── figures
    └── graph.dot

Running latexmk -r latexmk -norc working.tex compiles just fine, creates a figures/graph.pdf and an output pdf.

But running latexmk -r latexmk -norc non-working.tex yields the following error:

! LaTeX Error: File `graph' not found.

And it also does not say

Latexmk: applying rule 'cusdep dot pdf figures/graph'...
Rule 'cusdep dot pdf figures/graph': File changes, etc:
   Non-existent destination files:

as the working run does.

For completeness:

$ latexmk --version
Latexmk, John Collins, 10 Nov 2013. Version 4.39

Thanks for the help.


# Use "bin" as output directory
$out_dir = "bin";

# Build pdf with pdflatex
$pdf_mode = 1;

# Additional options for pdflatex
$pdflatex = "pdflatex -shell-escape %O %S";

# Use pdflatex recorder functionality
$recorder = 1;

# Custom dependency to convert dot files to pdfs
add_cus_dep('dot', 'pdf', 0, 'dot2pdf');
sub dot2pdf {
    system("dot -Tpdf \"$_[0].dot\" > \"$_[0].pdf\"");






digraph A {

1 Answer 1


The easiest work around is to create a first version of the file figures/graph.pdf by hand (e.g., by running the dot command yourself from the command line). After that latexmk will detect any further changes in the .dot file and remake the .pdf file automatically when necessary.

This is obviously undesirable.

The problem is that information on the graphicspath is not in any of the relevant files that latexmk reads (i.e., not in either the .log or the .fls files). Deliberately, latexmk doesn't examine the .tex file, because in general parsing .tex files is hard.

  • Thanks for the clarification on why latexmk doesn't work with \graphicspath. Since I only have one graphics subfolder I now chose to patch my \includegraphics such that it automatically adds figures/ before every file.
    – Artemis
    Oct 14, 2014 at 7:07

You must log in to answer this question.

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