Tuesday, August 13, 2013

Using the glossary package in LaTeX

My dissertation includes a lot of Sanskrit terms. For the benefit of my readers, I'm including a glossary which will have the terms and their definition.

The package I'm using for this is the glossary package, which you can read about here. The steps include, basically,

0. Create a document called "glossary.tex" with entries
1. Call the package: \usepackage{glossary}
2. Load the external file: \loadglsentries{glossary}
3. If you like, set a particular style: \glossarystyle{altlistgroup}
4. Tell LaTeX to make the glossary: \makeglossary
5. At the appropriate place in your document, print the glossary: \printglossaries
6. If you want to print all entries, not just the ones you mark in your text, add: \glsaddall
7. Finally, add the glossary to your table of contents: \addcontentsline{toc}{chapter}{Glossary}

The steps in compiling are supposed to be: XeLaTeX + BibTeX + MakeGlossaries + XeLaTEx

Problem. TeXWorks doesn't have the "MakeGlossaries" option. So my compiler kept stopping, telling me "can't find input index file."

After a lot of searching, I found the solution: just add my own "makeglossaries" option to the list of processes in TeXWorks. This website has instructions. You go to TeXWorks > Preferences > Typesetting, and add a processing tool. Name it "makeglossaries" (or whatever you'd like, really), enter the program "makeglossaries" (which should be already installed somewhere---don't worry about the full pathname), and add a single argument: "$basename" so that your main filename will be passed to the makeglossaries process.

That's it.

One last thing, which I found in the documentation for the package: if you want to suppress page numbers (I didn't want to index every instance of these terms), you can call the package with the option "nonumberlist." My resulting glossary looks like this, with just two sample entries:

Note: be careful not to add a period at the end of your final sentence in the glossary file. One will be automatically added for you, and if you put your own, the result will be ".."