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?


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 (!)

2 Answers 2


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;
    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.

  • 1. 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, 2022 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. Jan 25, 2022 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. Jan 25, 2022 at 17:03
  • Please have a look at my modified version...
    – einpoklum
    Jan 25, 2022 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. Jan 25, 2022 at 19:16

Adapting @JohnCollins' answer to some observations in answers to the linked question:

  • Propagating silent mode
  • Wrapping filenames with double-quotes in case of spaces or other name weirdness.
  • Better (?) support for different directories for inputs and outputs <- Not sure that's actually meaningful, feel free to comment
  • Not neglecting to add to the set of generated extensions
add_cus_dep( 'acn', 'acr', 0, 'run_makeglossaries' );
add_cus_dep( 'glo', 'gls', 0, 'run_makeglossaries' );
add_cus_dep( 'ntn', 'not', 0, 'run_makeglossaries' );

push @generated_exts, 'glo', 'gls', 'glg';
push @generated_exts, 'acn', 'acr', 'alg';
push @generated_exts, 'ntn', 'not', 'nlg';

$clean_ext .= " acr acn alg glo gls glg ist not ntn";

sub run_makeglossaries {
    my $dir = dirname($_[0]);
    my $base_name = basename($_[0]);

    my $return;
    if ( $silent ) {
        $return = system "makeglossaries", "-q", "-d", "$dir", "$base_name";
    else {
        $return = system "makeglossaries", "-d", "$dir", "$base_name";
    return $return;
  • Yes, it's good to use the -d option to makeglossaries instead of the pushd and popd trick. Similarly for obeying the $silent setting. As for the double quotes, the quotes around $dir are not needed; they are part of perl's syntax and aren't passed to system. The critical thing is that the arguments to system are a list rather than a string. With a string, there would have to be (escaped) quotes, but not with a list. [You'll have to look at the Perl documentation to get the details :-)] Jan 27, 2022 at 22:00
  • I suggest you just edit my answer to put in the improvements. It saves a bit of effort for readers of the answer(s). Jan 27, 2022 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .