I have many documents with glossaries which I used to build using this script:

pdflatex "$documentname.tex"
makeglossaries "$documentname"
pdflatex "$documentname.tex"
pdflatex "$documentname.tex"
makeindex -s "$documentname.ist" -o "$documentname.gls" "$documentname.glo"
pdflatex "$documentname.tex"

The line pdflatex "$documentname.tex" could probably appear less often but I thought that safe is safe.

I use AUCTeX, so I can build (and view) documents via C-c C-c. It builds a document and tells me when to press the combination again to run LaTeX, again. It even works when BibTeX is involved and runs that. But in the case of the documents with a glossary, it doesn't build the glossaries. How can this be achieved?

Can you make it so C-c C-c calls itself until (inclusive) the PDF is opened? For one document, I have to press it 8 times (8 times C-c C-c, not 8 times C-c) which gets quite tiresome.

  • 2
    Maybe set it up so C-c C-c calls latexmk instead. – John Kitchin May 14 '17 at 13:27
  • @JohnKitchin Unfortunately, I'm given documents which don't compile via latexmk (tested it via the latexmk command on the command line). Furthermore, this doesn't resolve the glossary problem. – UTF-8 May 14 '17 at 14:22
  • See tex.stackexchange.com/questions/1226/…. Why don't your documents compile via latexmk? – John Kitchin May 14 '17 at 14:56
  • @UTF-8 the easier solution is to ask the author of glossaries package to issue a warning in the log when it's necessary to run a program like makeglossaries. AUCTeX would be able to catch that warning and run the program. – giordano May 14 '17 at 16:30
  • @giordano "AUCTeX would be able to catch that warning and run the program." Wouldn't this require a change in AUCTeX so that after catching the (as of yet nonexistent) warning, AUCTeX runs makeglossaries? So I'd first have to ask the maintainers of glossaries to include the warning and then ask the maintainers of AUCTeX to handle the warning. – UTF-8 May 15 '17 at 12:57

It is enough to use latexmk and to let it know:

  • about the extensions of the files it has to check,
  • what to do if these files change.

That may be done in a .latexmkrc configuration file, e.g. in your root folder, containing something like this (Perl syntax):

add_cus_dep('glo', 'gls', 0, 'makeglossaries');
add_cus_dep('acn', 'acr', 0, 'makeglossaries');
sub makeglossaries{
    system( "makeglossaries \"$_[0]\"" );
  • The problem with using latexmk is that some documents I don't really control (I only make small fixes) can't be built using latexmk. If I were to substitute my built shortcut, I'd have to have a second one for building those documents and always had to remember which kind of document I'm building. – UTF-8 May 18 '17 at 22:21
  • 1
    @UTF-8 Whether running latexmk or not on a per document basis should be possible with AUCTeX's "Local Variables". – Denis Bitouzé May 18 '17 at 22:31

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.