[Tex/LaTex] latexmk and nomencl

latexmknomenclature

I'm trying to implement the nomencl package in my Master's thesis, but I'm experiencing serious trouble when it comes to make latexmk/makeindex create or update the nls file. I ended up creating the nls file manually from terminal (according to the nomencl documentation), but it won't update. I'm using TeX Live and Sublime Text 2 with LaTeXTools.

So, according to quite wide web I'm not the only one having troubles making nomencl and latexmk/makeindex communicate properly. According to one thread, I tried to add the following code to a latexmkrc file:

# for nomenclature
add_cus_dep("nlo", "nls", 0, "nlo2nls");
sub nlo2nls {
    system("makeindex $_[0].nlo -s nomencl.ist -o $_[0].nls -t $_[0].nlg");
}

I found no less than 8 latexmkrc files on my Mac, none of them located according to the latexmk documentation, and with no response to print('Hello, world!'); added to any of the files. I also tried to make a latexmkrc file in /opt/local/share/latexmk/LatexmK (and /opt/local/share/latexmk, just in case). Neither responds to

Hello, world!

My question is: how do I get the nls file to be created and updated automatically?

Best Answer

Just in case you want latexmk, the first step is to verify your current version with latexmk -v at the command line/terminal; current version is 4.35, dated 11 Nov 2012. Otherwise update your TeXlive distribution or update to the latest via latexmk at ctan.

Add the custom dependency commands depending on your requirements in a .latexmkrc file in your home directory using Terminal (Linux). For your nomencl example see examplerc scripts at ctan

  gedit $HOME/.latexmkrc 

with the following contents

 # Custom dependency and function for nomencl package 
 add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
 sub makenlo2nls {
 system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
 }

Then it should work with latexmk, it worked for me at least.

Related Question