3

I've started using the make-glossaries package, and am creating more than one glossary. Unfortunately, my latexmk calls seem to skip calling makeglossaries, so my build doesn't conclude. I'm using a non-main-type glossary, with:

\newglossary[nlg]{notation}{not}{ntn}{Notation and Abbreviations}

and the command-line I'm running to build my document is:

latexmk -pdf -outdir=aux/ -auxdir=aux/ -pdflatex="xelatex -shell-escape %O %S" my_doc

if I invoke this, the end of latexmk's console output is:

Output written on aux/my_doc.pdf (37 pages).
Transcript written on aux/my_doc.log.
Latexmk: Examining 'aux/my_doc.log'
=== TeX engine is 'XeTeX'
Latexmk: Found input bbl file 'aux/pubinfo.bbl'
Latexmk: Missing input file: 'my_doc.not' from line
  'No file my_doc.not.'
Latexmk: Found input bbl file 'aux/my_doc.bbl'
Latexmk: Found input bbl file 'aux/pubinfo.bbl'
Latexmk: Log file says output to 'aux/my_doc.pdf'
Latexmk: Found bibliography file(s) [front/pubinfo.bib]
Latexmk: Found bibliography file(s) [back/general.bib]
Latexmk: All targets (aux/my_doc.pdf) are up-to-date

Now, I have read:

How to make Latexmk use makeglossaries?

but the .latexmkrc file suggested there is not what I need:

add_cus_dep('glo', 'gls', 0, 'makeglo2gls');
sub makeglo2gls {
    system("makeindex -s '$_[0]'.ist -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo");
}

it uses makeindex rather than makeglossaries; and needs a dependency for each glossary file type. Can I replace it with something more appropriate, which actually does cause makeglossaries to work? Also, is it adapted to the use the aux/ subdir?

If not, what can I do to trigger the execution of makeglossaries?


Note:

To complete processing "semi-manually", I add the following commands after the first latexmk call:

makeglossaries -d aux/ my_doc
rm aux/my_doc.pdf
latexmk -pdf -outdir=aux/ -auxdir=aux/ -pdflatex="xelatex -shell-escape %O %S" my_doc

... and then everything proceeds fine. But without removing the .pdf, it still doesn't work (!)

einpoklum
  • 12,311

2 Answers2

4

The suggestion you mention for the .latexmkrc file is out-of-date. See the file glossary_latexmkrc in the example_rcfiles for the current recommendation. From what's in that file, the code for you to put in a .latexmkrc file is

add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
add_cus_dep( 'ntn', 'not', 0, 'makeglossaries' );
$clean_ext .= " acr acn alg glo gls glg ist not ntn";

sub makeglossaries { my ($base_name, $path) = fileparse( $_[0] ); pushd $path; my $return = system "makeglossaries", $base_name; popd; return $return; }

There's no simple way of persuading latexmk to know the extensions of the files for your notation glossary, so you have to add the appropriate custom dependency. But you don't need a new subroutine for it.

The above code also works when you use an aux dir. That's done by the trick with pushd and popd.

I've also added a line to specify that the glossary files are to be deleted when you do a clean-up.

John Collins
  • 11,183
  • 3
  • 32
  • 33
  • Can you explain what $clean_ext does? 2. Will I see multiple (redundant) invocations of makeglossaries, or just one? 3. +1 of course.
  • – einpoklum Jan 24 '22 at 19:14
  • $clean_ext has a list of extensions of files that are deleted when you do a clean up operation (by the -c or -C option on the command line to latexmk). So the setting of $clean_ext in the answer ensures that the files used for the glossaries will be included in the clean up, as is normally desirable. Omit that line if you want to preserve those files in a clean up. – John Collins Jan 25 '22 at 15:12
  • Despite the fact that there are 3 custom dependencies, for 3 different types of glossary file, you won't actually see redundant runs, at least in my tests. – John Collins Jan 25 '22 at 17:03
  • Please have a look at my modified version... – einpoklum Jan 25 '22 at 18:29
  • I have to backtrack on my previous comment about extra runs of makeglossaries (I was a victim of too simple a test). There is no simple way of avoiding the extra runs, other than reverting to the old method. But generally makeindex runs fast even for a large document, so there is little penalty for the extra runs of makeglossaries. – John Collins Jan 25 '22 at 19:16
  • Concerning your modified version, where is it? I don't see any edits to the question or the answer. – John Collins Jan 25 '22 at 19:18
  • Posted a new answer - it's a modification of your script. – einpoklum Jan 25 '22 at 19:48