Abstract
This document is a brief guide to the glossaries package for beginners who find the size of the main user manual daunting and, as such, it only covers the basics. For more advanced topics, see the main user manual.
You need to have the glossaries package installed. You also need to have the following packages installed: ifthen, xkeyval (at least version 2.5f), xfor, amsgen and etoolbox. You may also need longtable, supertabular and array, depending on what glossary style you want to use. All these packages can be downloaded from CTAN if you don’t have them installed. See “Installing things on a (La)TeX System” for further assistance.
In addition, you need an indexing application. The glossaries package is configured to use either makeindex or xindy. Makeindex should be available on all TEX systems. It’s possible you may not have xindy installed, but it can be downloaded from the xindy home page. MiKTeX users may find the Xindy for MiKTeX thread on the LaTeX Community Forum helpful.
The glossaries package provides a helper Perl script called makeglossaries which will act as an interface to makeindex or xindy. If you want to use makeglossaries or xindy, you need to have Perl installed. If you don’t have Perl installed, you can still use glossaries but you can only use it with makeindex.
The most obvious things to do is to remember to load the glossaries package:
If you want to use xindy rather than makeindex to sort the glossaries, you need to specify this in the package options:
Other package options are described in Package Options in the main glossaries user manual.
Next, you need to enable the creation of the various external files that are required by the indexing application. This is done using:
You must define terms or symbols before you can use them in the document. This is best done in the preamble. Each term is defined using:
where ⟨label⟩ is a unique label used to identify the term. The second argument, ⟨settings⟩, is a key=value comma separated list that is used to set the required information for the term. A full list of available keys can be found in Defining Glossary Entries in the main glossaries user manual. The principle keys are name and description.
For example, to define the term “electrolyte”:
In the above example, the label and the name happen to be the same. In the next example, the name contains a ligature but the label doesn’t:
In this case the label is oesophagus. Note that in this case, the plural has to be specified using the plural key since it isn’t formed by simply appending the letter “s”.
When you define terms, it is important to remember that they will be sorted by an external application that doesn’t interpret LATEX commands. Xindy is a little more TEX-aware than makeindex, but for this example they will both mis-sort \oe sophagus. Xindy will ignore the \oe␣ part and will sort it according to sophagus, so it will be placed with the terms starting with an “s”. Makeindex, on the other hand, will sort it according to \oe␣sophagus which starts with a symbol (the backslash), so it will end up in the symbol group. You therefore need to specify how to sort the term:
Note, however, that if you use the inputenc package and xindy, you can use the encoded character œ rather than \oe and xindy will sort it correctly:
If the name starts with an accented character, the first character must be grouped:
or
The name can also be a symbol, but you will also need to specify the sort key. For example:
It’s also possible to have a name and a symbol. For example:
Note, however, that not all glossary styles display the symbol in the glossary.
Once you have defined a term, you can use it in the document. The glossaries package provides a number of commands that are described in Links to Glossary Entries in the main glossaries user manual. Here, I shall just cover the main commands:
This prints the term associated with ⟨label⟩. Using the example in the previous section, \gls{oesophagus} will display œsophagus. If the hyperref package has also been loaded, the term will also be hyperlinked to the relevant entry in the glossary.
This prints the plural of the term associated with ⟨label⟩, so \glspl{oesophagus} will display œsophagi. Again, the text will be a hyperlink to the relevant entry in the glossary, if hyperlinks are defined.
There are also versions that convert the first character to upper case if you need to start a sentence with a term:
and
For example:
Note that these commands all have two optional arguments that aren’t discussed here, but they are described in Links to Glossary Entries in the main glossaries user manual.
You can, instead, use commands such as
See Using Glossary Terms Without Links in the main glossaries user manual.
The glossaries package also allows you to define acronyms. By default, acronyms will be added to the main glossary, but if you use the acronym package option, acronyms will be placed in a separate list of acronyms:
There are other options that govern how acronyms appear. For further details, see Acronyms in the main glossaries user manual.
Acronyms must be defined before use and are defined using:
where ⟨label⟩ is the label identifying the acronym, ⟨abbrv⟩ is the abbreviated form and ⟨full⟩ is the fully expanded text. For example:
Once the acronym is defined, it can be used in the same way as any other glossary term with commands such as \gls and \glspl. On first use, the default will display ⟨full⟩ (⟨abbrv⟩). On subsequent use, only the abbreviation will appear. For example:
If this is the first time this term has been used, the above would produce:
A support vector machine (svm) was implemented.
A svm was implemented.
or you can reset all acronyms using
For further details on resetting and unsetting acronyms, see Unsetting and Resetting Entry Flags in the main glossaries user manual.
In order to display the sorted list of terms, you first need to use
at the place where you want the glossary and list of acronyms to appear. Note that \printglossaries won’t produce any text the first time you create your document, as an external indexing application needs to be used to sort and collate the entries. Creating the completed document is therefore at least a three step process.
Suppose your document is called myDoc.tex, then you need to:
in a terminal or command prompt. If you are using a front-end (such as WinEdt or TeXnicCenter) and you want it to automatically run makeglossaries when you build your document, you will need to consult the front-end’s documentation.
If you don’t have Perl installed, you will need to call makeindex or xindy explicitly. This is more complicated and is described in Generating the Associated Glossary Files in the main glossaries user manual.
Note that sometimes you may have to repeat steps 2 and 3.
The appearance of the glossary depends on the glossary style in use. The default style uses the description environment, but there are many other styles available. These are described in Glossary Styles in the main glossaries user manual. By default, a number or list of numbers will appear after each entry in the glossary. This indicates the page (or pages) on which the term was used. This list can be suppressed using the nonumberlist package option:
Further information can be found in the main glossaries user manual and there is also an article on the glossaries package on the LATEX Community’s Know How section.