How can I use glosseries with latexmk if I use outdir and auxdir parameters? I keep getting the .gls not found...

Here is my latexmk build script:

latexmk -outdir=out -auxdir=out -g -f -bibtex -dvi- -pvc -pdflatex="xelatex -synctex=0 %O %S" -pdf $1

If I remove the auxdir and outdir param, everything works fine. Any help appreciated.

EDIT: Stop up-voting the answer unless you checked it yourself and it works! Because it does not work for me.

  • If you are using Linux, makelatex is a similar program written in Python which handles glossaries properly while keeping aux files in a subdirectory. Let me know if you encounter any problems with it.
    – ScottKu
    Jun 15, 2012 at 20:47
  • Wow, that looks amazing. Does it have a continuous mode like latexmk where it watches for changes in source files? Jun 16, 2012 at 0:14
  • Also are there cmd-line options. Jun 16, 2012 at 0:19
  • 1
    makelatex -l will continually loop and rebuild the document whenever the source files change. There are command line options which you can see by running makelatex --help
    – ScottKu
    Jun 16, 2012 at 16:14
  • @ScottKu You should really put that into some kind of easy-to-install repository. latexmk already comes with latex live. And I can't find makelatex in arch-linux repos either. Just a suggestion. Jun 19, 2012 at 17:42

1 Answer 1


The problem is that the makeglossaries script fails when it is called with a filename with a path component, e.g., makeglossaries out/try. This can be worked around by defining the necessary custom dependency as follows

add_cus_dep('glo', 'gls', 0, 'makeglossaries');
sub makeglossaries {
   my ($base_name, $path) = fileparse( $_[0] );
   pushd $path;
   my $return = system "makeglossaries $base_name";
   return $return;

(Note that pushd and popd are subroutines defined by latexmk that do the same as the corresponding commands in UNIX shells.)

  • Here is the output I am getting: Run number 1 of rule 'cusdep glo gls Main' ------------ For rule 'cusdep glo gls Main', running '&do_cusdep( )' ... Latexmk: In trying to apply custom-dependency rule to make 'Main.gls' from 'Main.glo' the source file has disappeared since the last run Latexmk: applying rule 'pdflatex'... Jun 13, 2012 at 1:56
  • And at the end: Latexmk: Missing input file: 'Main.gls' from line 'No file Main.gls.' Collected error summary (may duplicate other messages): cusdep glo gls Main: failed to create output file Jun 13, 2012 at 1:57
  • 2
    Hellou... anyone there? Why are people upvoting this answer if it does not work??? Jun 19, 2012 at 17:43
  • @drozzy: I’ve tested the solution with the current CTAN versions of latexmk and the glossaries package on Debian and it definitely works. Check your versions of latexmk and the glossaries package and provide a working minimal example. Otherwise, it’s difficult to help you.
    – mhp
    Jun 20, 2012 at 9:20
  • Thank you!!! I was already looking for a solution for two weeks!
    – Unchained
    Feb 14, 2021 at 14:33

You must log in to answer this question.

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