Consider the following latexmkrc configuration file (say latexmkrc.tex) containing a custom dependency which is supposed to run the texindy subroutine whenever a .ind file is out-of-date with respect to the corresponding source file:
# $makeindex = 'texindy'; #$
add_cus_dep('idx', 'ind', 0, 'texindy');
sub texindy{
system("texindy \"$_[0].idx\""); #$
}
$pdf_mode = 1; #$
Now, consider a .tex file (say test.tex) processed with:
latexmk -g -norc -r latexmkrc.tex test
where:
-goption to forcelatexmkto process the document fully (just for the example),-norcoption just to be sure no otherlatexmkconfiguration file thanlatexmkrc.texis taken in account.
Then, the following happens:
- Running
pdflatex -recorder "test.tex". - Running
makeindex -o "test.ind" "test.idx". - Running
pdflatex -recorder "test.tex".
The trouble is with step #2, latexmk creating a new rule:
=== Creating rule for 'cusdep idx ind test'
Latexmk: applying rule 'makeindex test.idx'...
Rule 'makeindex test.idx': File changes, etc:
Non-existent destination files:
'test.ind'
------------
Run number 1 of rule 'makeindex test.idx'
------------
------------
Running 'makeindex -o "test.ind" "test.idx"'
ignoring the custom dependency and subroutine in latexmkrc.tex that is supposed to lead to: texindy -o "test.ind" "test.idx" instead.
As a workaround, one could comment out the line
# $makeindex = 'texindy'; #$
in latexmkrc.tex but I'm still puzzled: why latexmk does ignore my (index) custom dependency and subroutine?
Minimal complete example:
\documentclass{article}
\usepackage[xindy]{imakeidx}
\usepackage{filecontents}
\makeindex
\begin{filecontents*}{latexmkrc}
# $makeindex = 'texindy'; #$
add_cus_dep('idx', 'ind', 0, 'texindy');
sub texindy{
system("texindy \"$_[0].idx\""); #$
}
$pdf_mode = 1; #$
\end{filecontents*}
\begin{document}
Foo\index{Foo}
\printindex
\end{document}
latexmkalready has a rule for converting.idxfiles to.ind, so it doesn't consider the "new" rule. (See this answer to a similar problem I had a few years ago, but where only the input extension was the same: http://tex.stackexchange.com/a/37730/9517 ) – T. Verron Oct 21 '16 at 13:12latexmk's rule is first deleted byremove_cus_dep('idx', 'ind');, the trouble still occurs. – Denis Bitouzé Oct 21 '16 at 13:18remove_cus_dep, I don't think built-in rules arecus_deps. – T. Verron Oct 21 '16 at 13:49;)This answer evolved a lot due to follow-up questions by other commenters, the version of that code in my.latexmkrcis just 3 lines long. – T. Verron Oct 21 '16 at 14:28latexmkprovides thismakeindexvariable. – T. Verron Oct 21 '16 at 14:54