Glossaries Package and LaTeXTools

I used the provided answers on TEX.se a lot while writing my Bachelor Thesis but couldn´t find an answer on the following question:

How do I use the LaTeXTools build-system with the glossaries package to have a list of acronyms somewhere in my document?

My MWE:

\documentclass{article}
\usepackage[acronym,nomain,toc,shortcuts,xindy]{glossaries}
\makeglossaries

\newacronym{Mr}{M$_r$}{Remanence}
\newacronym{Hc}{H$_c$}{Coercivity}

\setacronymstyle{long-short}
\begin{document}
\tableofcontents

\newpage
Here's a \ac{Mr} glossary entry.
\printglossaries

\end{document}


With my MWE on Sublime Text 3 and the latest version of LaTeXTools the following output was produced: Using the Terminal (OS X and TeXLive 2016) with the following commands (thesis.tex is my file)

xelatex thesis
makeglossaries thesis
xelatex thesis
xelatex thesis


the correct output was produced:

Okay now why don´t I just use the Terminal: I have way more packages that require extra commands etc. - That might be obvious

Why don´t I use a TEX-specific editor: Until now the LaTeXTools Plugin does a great job and sublime text is just one of the most convenient text-editors i´ve seen so far so I would like to keep on going with it.

I already found a question related to this which is not quite answered (I just can´t link to it because i already used the 2 links I have with my little reputation...)

Thanks in Advance for any help!

There are a few different ways this could be approached.

The traditional builder that LaTeXTools uses launches latexmk, so you can solve the issue the same way you would for latexmk, i.e., add a .latexmkrc file to the directory containing your main tex document with the following contents:

add_cus_dep('glo', 'gls', 0, 'makeglossaries');
sub makeglossaries {
if ($silent) { system("makeglossaries -q \"$_[0]\"");
} else{
system("makeglossaries \"$_[0]\""); } } push @generated_exts, 'glo', 'gls', 'glg'; push @generated_exts, 'acn', 'acr', 'alg';$clean_ext .= ' %R.ist %R.xdy';


I've based this on both the latexmk example file and this answer to a similar question.

Alternatively, as suggested in this question (I assume this is the one you were referring to), is to use the script builder. To do this, in your LaTeXTools.sublime-settings file (or, better, in the settings section of your Sublime project file, you need to change the builder setting to script and then change the builder_settings block to something like this:

"builder_settings": {
"osx": {
"script_commands": [
"pdflatex -interaction=nonstopmode -synctex=1",
"makeglossaries",
"pdflatex -interaction=nonstopmode -synctex=1",
"pdflatex -interaction=nonstopmode -synctex=1"
]
}
}


Personally, I'd choose the former of these, as the second option will run the whole script every time you build, which could take an unnecessary amount of time if you're working on a really long document.

• Thanks a lot for the fast reply! I now implemented your first (and recommended) answer in my MWE - it works! But - and now I´ll try to figure out why - my original document is still not compiling with the error TeX STOPPED: File ended while scanning use of \\newacronydescription\glspostdescription \space \glossaryentrynumbers {\relax \glsXpageXglsnumberformat TeX reports the error was in file:91 Do you have any idea to that? – lionade Sep 15 '16 at 7:31
• it was just a bracket missing... as always, isn´t it? :D following your linked post i also added push @generated_exts, 'glo', 'gls', 'glg'; push @generated_exts, 'acn', 'acr', 'alg'; \$clean_ext .= ' %R.ist %R.xdy'; to the .latexmkrc file to add the files the cleanup-ability of latexmk =) Great Thanks again! – lionade Sep 15 '16 at 8:15
• With LatexTools glossaries usually print fine for me. However, if I use xindy as the indexer like in \usepackage[xindy,toc,nonumberlist]{glossaries} it won't. This fixed it for me – GeeF Dec 4 '17 at 18:03