I am trying to get a document to print a list of urls, and I have the sample here that needs me to run makeindex in between the invocations of pdflatex. latexmk -pdf doesn't seem to do it automatically, although I thought it would convert .idx files to .ind files and re-run pdflatex automatically.

Manually, this is how it works: I have a main.tex file.

$ pdflatex main      # produces main-url.idx and main-url.mst
$ makeindex main-url # produces main-url.ind
$ pdflatex main      # produces a pdf with the index .ind file just created

As I understand it, latexmk takes care of running makeindex automatically, but when I run it on a clean directory (with only main.tex), the .ind file is never created, and the index doesn't end up in the pdf.

What I have tried: First, I tried adding the following dependency to a local latexmkrc file, but that didn't work (I think because there is already a rule to turn .idx files into .ind files:

# support for the printing urls:
add_cus_dep('idx', 'ind', 0, 'makeurlindex');
sub makeurlindex {
  return system("makeindex \"$_[0].idx\"");

Then I tried changing the output extension to .ndx and having the custom dependency as follows, but again, no dice:

# support for the printing urls:
add_cus_dep('ndx', 'ind', 0, 'makeurlindex');
sub makeurlindex {
  return system("makeindex \"$_[0].ndx\"");

Additionally, I tried changing the output file to main.idx and updated the custom dependency accordingly, but it didn't work, either.

Finally, I tried making the dependency go from .mst to .ind, but that didn't work.

How can I make latexmk act on this dependency?

  • I think it should be just the extension without the leading dot in the first two arguments of add_cus_dep. – Nicola Talbot Dec 10 '17 at 13:26
  • @NicolaTalbot Thanks! You are correct -- I removed the leading dot and fixed it above (and didn't have the leading dot in my own doc). Still not difference. :( – Chris Gregg Dec 10 '17 at 14:37

I determined a way to use the regular idx->ind dependency handling, which was to provide a log message in the latex file:

\wlog{Writing index file \jobname-url.idx}

The extra log message is to force a newline before the actual message.

This enabled the latexmk script to find the index message and handle it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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