I am using latexmk to compile my document, and have written a custom dependency rule to generate some files to include. The processing involves creating some intermediate files which I'd like to clean with -c
. However, these intermediate files are only removed if I set $cleanup_includes_generated = 1;
which results in the output PDF being deleted also.
For a minimal working example, use the following latexmkrc
file which simply copies a file to an intermediate and then final destination. It uses the rdb_add_generated()
routine mentioned by John Collins in this answer about cleaning custom dependencies.
$pdf_mode = 1;
$cleanup_includes_cusdep_generated = 1;
add_cus_dep('txt', 'inc', 0, 'test_dep');
sub test_dep {
system("cp $_[0].txt $_[0].tmp");
system("cp $_[0].tmp $_[0].inc");
rdb_add_generated("$_[0].tmp");
}
Use a simple TeX document main.tex
:
\documentclass{article}
\begin{document}
\input{message.inc}
\end{document}
And an even simpler file message.txt
to process:
Hello world!
Running latexmk -interaction=nonstopmode
creates a file database main.fdb_latexmk
which includes the message.tmp
intermediate file. However, latexmk -c
and latexmk -C
only remove the message.inc
file and leave the intermediate one.
Changing $cleanup_includes_cusdep_generated = 1;
to $cleanup_includes_generated = 1;
in the latexmk config results in the intermediate file being deleted. However, this results in latexmk -c
behaving the same as latexmk -C
and removing the output PDF, which is not ideal.
I suspect rdb_add_generated()
is adding the intermediate file to the general list of generated files rather than a list of files generated by custom dependencies. Is there some way to mark it as a custom generated file, or am I stuck with choosing between leaving the intermediate files uncleaned or deleting all generated files?
make
, and calllatexmk
frommake
to do the things thatmake
can't do - in particular, automatically re-running LaTeX enough times for cross references etc to stabilize.