TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to use latexmk in a Makefile, so I've read the manual section on that. However, the dependency generation step seems less than ideal. Specifically, it seems that latexmk can only show dependencies after fully building an output file (which can take a long time in my case). Is there a way to have latexmk only output dependencies to a file and not mark the actual output file as up-to-date?

I've tried the following rule in my Makefile, but it seems to mark the output file as up-to-date. I'd also think it could run multiple times (or think it has failed) depending on what's in the log file.

%.d: %.tex
    @echo "Generating $@ from $<"
    @set -e; \
     $(LATEXMK) -M -MF $@ -quiet -pdf \
      -pdflatex="echo Generating dependencies from %T" $<
share|improve this question
This might be a problem as some of the dependencies arise only during compilation (like tikz-externalize, automatic epstopdf etc.). Even bibliography usage is actually known only during the compilation. – yo' Aug 22 '12 at 16:50
up vote 3 down vote accepted

@tohecz: You are correct.

The problem is that the dependencies depend in a complicated way on the detailed contents of the TeX file (and all the files it calls in, including the class file and the style files). The only easy way to determine the dependencies is to run pdflatex (or latex as appropriate), and then analyze the resulting files (the relevant ones are the .fls, .log and .aux files). If the .tex file changes, then both the .pdf and the dependency information are simultaneously out of date.

Therefore, if you want to run pdflatex to determine the dependencies, you get a new .pdf file as a side effect. So there's no point to trying to update the dependency information without updating the .pdf file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.