The glossaries package v5.1: a guide for beginners

## Abstract

The glossaries package is very flexible, but this means that it has a lot of options, and since a user guide is supposed to provide a complete list of all the high-level user commands, the main user manual is quite big. This can be rather daunting for beginners, so this document is a brief introduction just to help get you started. If you find yourself saying, “but how can I do…?” then it’s time to move on to the main user manual.

I’ve made some statements in this document that don’t actually tell you the full truth, but it would clutter the document and cause confusion if I keep writing “except when …” or “but you can also do this, that or the other” or “you can do it this way but you can also do it that way, but that way may cause complications under certain circumstances”.

[top]

## 1. Getting Started[link]

As with all packages, you need to load glossaries with `\usepackage`, but there are certain packages that must be loaded before glossaries, if they are required: hyperref, babel, polyglossia, inputenc and fontenc. (You don’t have to load these packages, but if you want them, you must load them before glossaries.)

ℹ
If you require multilingual support you must also install the relevant language module. Each language module is called glossaries-〈language〉, where 〈language〉 is the root language name. For example, glossaries-french or glossaries-german. If a language module is required, the glossaries package will automatically try to load it and will give a warning if the module isn’t found.

Once you have loaded the glossaries package, you need to define your terms in the preamble and then you can use them throughout the document. Here’s a simple example:

    🖹\documentclass{article}
    \usepackage{glossaries}
    % define a term:
    \newglossaryentry{ex}{name={sample},
     description={an example}}
    \begin{document}
    Here's my \gls{ex} term.
    \end{document}

The above defines a simple term identified by the label “ex”. When the term is referenced by its label with `\gls`, the provided text (“sample”) is inserted into the document:
🖺
Here’s my sample term.
Note that a description has been given in the definition but it doesn’t appear in the document yet.

In general, it’s best to choose a label that’s easy to remember and makes the source code (reasonably) easy to read. In the above example, a better label would be “sample”, the same as the term itself. However, bear in mind that labels mustn’t contain non-expandable content. The next example defines a term that’s actually a symbol. In this case, the label must be different from the provided term, which contains the commands to typeset the symbol:

    🖹\documentclass{article}
    \usepackage{glossaries}
    \newglossaryentry{emptyset}{
     name={\ensuremath{\emptyset}},
     description={the empty set}}
    \begin{document}
    The empty set is denoted \gls{emptyset}.
    \end{document}

This produces:
🖺
The empty set is denoted \(\emptyset \).

The next example defines a term with the label “svm” that has both a long form (“support vector machine”) and a short form (“SVM”):

    🖹\documentclass{article}
    \usepackage{glossaries}
    \setacronymstyle{long-short}
    \newacronym{svm}{SVM}{support vector machine}
    \begin{document}
    First use: \gls{svm}. Second use: \gls{svm}.
    \end{document}

This has used a different command to define the term, but the term is still referenced with `\gls` in the same way as before. However, the text produced by `\gls` now varies:
🖺
First use: support vector machine (SVM). Second use: SVM.
In this case, the text (the “link text”) produced by ``\gls`{svm}` changed after the first use. The first use produced the long form followed by the short form in parentheses because I set the acronym style to long-short. The subsequent use just showed the short form.

I suggest you try the above examples to make sure you have the package correctly installed. If you get an “undefined control sequence” error for any of the examples provided in this guide, check that the version number at the top of this document matches the version you have installed. (Open the log file and search for the line that starts with “Package: glossaries” followed by a date and version.)

ℹ
Be careful of fragile commands. If a command causes a problem when used in one of the `\newglossaryentry` fields, consider adding `\glsnoexpandfields` before you start defining your entries. Where possible use robust semantic commands.

Abbreviations are slightly different if you use the extension package glossaries-extra (which needs to be installed separately). This automatically loads glossaries so you don’t need to explicitly load it:

    🖹\documentclass{article}
    \usepackage{glossaries-extra}
    % commands provided by glossaries-extra:
    \setabbreviationstyle{long-short}
    \newabbreviation{svm}{SVM}{support vector machine}
    \begin{document}
    First use: \gls{svm}. Second use: \gls{svm}.
    \end{document}

Since long-short happens to be the default for `\newabbreviation` you may omit the `\setabbreviationstyle` line in this example.

If you still want to use `\newacronym` (rather than `\newabbreviation`) then you need the optional argument of `\setabbreviationstyle`:

    🖹\documentclass{article}
    \usepackage{glossaries-extra}
    \setabbreviationstyle[acronym]{long-short}
    \newacronym{svm}{SVM}{support vector machine}
    \begin{document}
    First use: \gls{svm}. Second use: \gls{svm}.
    \end{document}

In this example, if you omit the `\setabbreviationstyle` line you will notice a difference because the short-nolong style (not the long-short style) is the default with `\newacronym`. With the short-nolong style the first use simply shows just the short form.

ℹ
You can’t use `\setacronymstyle` with glossaries-extra.

If you like, you can put all your definitions in another file (for example, defns.tex) and load that file in the preamble using `\loadglsentries` with the filename as the argument. For example:

    🖹\loadglsentries{defns}

If you find you have a really large number of definitions that are hard to manage in a tex file, you might want to have a look at bib2gls (installed separately) which requires a bib format instead.

Avoid explicitly using formatting commands in abbreviation definitions as they can interfere with the underlying mechanism. Instead, the formatting should be done by the style. For example, suppose I want to replace `SVM` with ``\textsc`{svm}`, then I need to select a style that uses `\textsc`, like this (for the base glossaries style):

    🖹\documentclass{article}
    \usepackage{glossaries}
    \setacronymstyle{long-sc-short}
    \newacronym{svm}{svm}{support vector machine}
    \begin{document}
    First use: \gls{svm}. Second use: \gls{svm}.
    \end{document}

The abbreviation styles have a different naming scheme with glossaries-extra:

    🖹\documentclass{article}
    \usepackage{glossaries-extra}
    % commands provided by glossaries-extra:
    \setabbreviationstyle{long-short-sc}
    \newabbreviation{svm}{svm}{support vector machine}
    \begin{document}
    First use: \gls{svm}. Second use: \gls{svm}.
    \end{document}

With glossaries-extra you can have different abbreviation styles for different categories. Many of these styles have their own associated formatting commands that can be redefined for minor adjustments. See the glossaries-extra manual for further details or Gallery: Mixing Styles.

As you can hopefully see from the above examples, there are two main ways of defining a term: as a general entry (`\newglossaryentry`) or as an abbreviation (`\newacronym` or, with glossaries-extra, `\newabbreviation`).

🛈
Regardless of the method of defining a term, the term is always given a label which is used to uniquely identify the term (like the standard `\label`/`\ref` or `\cite` mechanism). The label may be the same as the text produced with `\gls` (provided it doesn’t contain any formatting commands) or may be completely different.

The labels are identified in bold in the following:

    🖹\newglossaryentry{elite}{name={élite},
     description={select group}}
    \newglossaryentry{set}{name={set},
     description={collection of distinct elements}}
    \newglossaryentry{sym.set}{
     name={\ensuremath{\mathcal{S}}},
     description={a set}}
    \newacronym{tool.cnc}{CNC}{computer numerical control}
    \newacronym{police.cnc}{CNC}{civil nuclear constabulary}
    \newacronym{miltary.cnc}{CNC}{commander in chief}

With modern TeX installations you should now be able to use UTF-8 characters in the label, but beware of active characters. For example, babel makes some punctuation characters, such as `:` (colon), active for certain languages. This means that the character behaves like a command which is unsuitable for a label.

For example, the following works:

    🖹\documentclass{article}
    \usepackage{glossaries}
    \newglossaryentry{sym:set}{name={\ensuremath{\mathcal{S}}},
     description={a set}}
    \begin{document}
    \gls{sym:set}
    \end{document}

However, if babel is loaded with french then the `:` (colon) character becomes active.

    🖹🛇\documentclass{article}
    \usepackage[T1]{fontenc}
    \usepackage[french]{babel}
    \usepackage{glossaries}

    % the colon : is a normal character here
    \newglossaryentry{sym:set}{
     name={\ensuremath{\mathcal{S}}},
     description={a set}}

    \begin{document}
    % the colon : is now an active character
    \gls{sym:set}
    \end{document}

You may find that the above example seems to work, but a problem will occur if hyperref and a glossary list are added to the document as the active character will interfere with the hyperlink target name.

ℹ
Don’t use `\gls` in chapter or section headings as it can have some unpleasant side-effects. Instead use `\glsentrytext` for regular entries and either `\glsentryshort` or `\glsentrylong` for acronyms. Alternatively use glossaries-extra which provides special commands for use in section headings and captions, such as `\glsfmttext` and `\glsfmtshort`.

The above examples are reasonably straightforward. The difficulty comes if you want to display a sorted list of all the entries you have used in the document. The glossaries-extra package provides an easy way of listing all the defined entries:

    🖹\documentclass{article}

    \usepackage[sort=none]{glossaries-extra}

    \newglossaryentry{potato}{name={potato},
     plural={potatoes},
     description={starchy tuber}}

    \newglossaryentry{cabbage}{name={cabbage},
     description={vegetable with thick green
       or purple leaves}}

    \newglossaryentry{turnip}{name={turnip},
      description={round pale root vegetable}}

    \newglossaryentry{carrot}{name={carrot},
      description={orange root}}

    \begin{document}
    Chop the \gls{cabbage}, \glspl{potato} and
    \glspl{carrot}.

    \printunsrtglossaries % list all entries
    \end{document}

However this method doesn’t sort the entries (they’re listed in order of definition) and it will display all the defined entries, regardless of whether or not you’ve used them all in the document, so “turnip” appears in the glossary even though there’s no ``\gls`{turnip}` (or similar) in the document.

The sort=none option isn’t essential in this case (there’s no other sort option available for this document), but it prevents the automatic construction of the sort value and so slightly improves the document build time.

This example document uses the same command (`\printunsrtglossaries`) that’s used with bib2gls (Option 4) but with bib2gls you instead need to use the record package option (not sort) and one or more instances of `\GlsXtrLoadResources` in the preamble (more on this later).

Most users prefer to have an automatically sorted list that only contains entries that have been used in the document, optionally with a page list (indexing). The glossaries package provides three options: use TeX to perform the sorting (Option 1); use makeindex or upmendex to perform the sorting (Option 2); use xindy to perform the sorting (Option 3). The extension package glossaries-extra provides a fourth method: use bib2gls (Option 4).

The first option (using TeX) is the simplest method, as it doesn’t require an external tool. It works best with at least version 3.0 of the datatool-base package, which is provided with datatool (and automatically loaded by glossaries). That version introduced the ability to provide localisation support, which needs to be installed separately. (See the datatool manual for further details.)

To use this method, add `\makenoidxglossaries` to the preamble (before the entries are defined) and put `\printnoidxglossaries` at the place where you want your glossary. For example:

    🖹\documentclass{article}

    \usepackage{glossaries}

    \makenoidxglossaries % use TeX to sort

    \newglossaryentry{potato}{name={potato},
     plural={potatoes},
     description={starchy tuber}}

    \newglossaryentry{cabbage}{name={cabbage},
     description={vegetable with thick green
       or purple leaves}}

    \newglossaryentry{turnip}{name={turnip},
     description={round pale root vegetable}}

    \newglossaryentry{carrot}{name={carrot},
     description={orange root}}

    \begin{document}
    Chop the \gls{cabbage}, \glspl{potato} and
    \glspl{carrot}.

    \printnoidxglossaries
    \end{document}

Try this out and run LaTeX (or pdfLaTeX) twice. The first run won’t show the glossary. It will only appear on the second run. This doesn’t include “turnip” in the glossary because that term hasn’t been referenced (with commands like ``\gls`{turnip}`) in the document.

The glossary has a vertical gap between the “carrot” term and the “potato” term. This is because the entries in the glossaries are grouped according to their first letter. If you don’t want this gap, just add nogroupskip to the package options:

    🖹\usepackage[nogroupskip]{glossaries}

or you may want to try out a style that shows the group headings:

    🖹\usepackage[style=indexgroup]{glossaries}

If you try out this example you may also notice that the description is followed by a full stop (period) and a number. The number is the location in the document where the entry was referenced (page 1 in this case), so you can look up the term in the glossary and be directed to the relevant pages. It may be that you don’t want this back-reference, in which case you can suppress it using the nonumberlist package option:

    🖹\usepackage[nonumberlist]{glossaries}

If you don’t like the terminating full stop, you can suppress that with the nopostdot package option:

    🖹\usepackage[nopostdot]{glossaries}

The glossaries-extra package has this option as the default, so if you want terminating full stop, you need to explicitly add it with the postdot option:

    🖹\usepackage[postdot]{glossaries-extra}

You may have noticed that I’ve used another command in the above examples: `\glspl`. This displays the plural form. By default, this is just the singular form with the letter “s” appended, but in the case of “potato” I had to specify the correct plural using the plural key.

Using TeX to sort the entries is the simplest but least efficient method. If you have a large glossary, then you will have a much faster build time if you use makeindex (Option 2) or xindy (Option 3) or bib2gls (Option 4). If you are using extended Latin or non-Latin characters, then upmendex or xindy or bib2gls are the recommended methods. These methods are described in more detail in §4.

The rest of this document briefly describes the main commands provided by the glossaries package. (Most of these are also available with glossaries-extra but may behave slightly differently.)

[top]

## 2. Defining Terms[link]

When you use the glossaries package, you need to define glossary entries before you can reference them. This is best done in the document preamble, as shown in the earlier examples, or in a separate file that’s input in the preamble.

These entries could be a word, phrase, abbreviation or symbol. They’re usually accompanied by a description, which could be a short sentence or an in-depth explanation that spans multiple paragraphs. The simplest method of defining an entry is to use:

📌
``\newglossaryentry`{〈label〉}{〈key=value list〉}`
where 〈label〉 is a unique label that identifies this entry. (Don’t include the angle brackets 〈 〉. They just indicate the parts of the code that you need to change when you use this command in your document.) The two most important keys are name and description:

    \newglossaryentry{〈label〉}
    {
      name={〈name〉},
      description={〈description〉},
      〈other options〉
    }

The 〈name〉 is the word, phrase or symbol you are defining, and 〈description〉 is the description to be displayed in the glossary.

This command is a “short” command, which means that 〈description〉 can’t contain a paragraph break. If you have a long description, you can instead use:

📌
``\longnewglossaryentry`{〈label〉}{〈key=value list〉}{〈description〉}`
In this case the name key is in the second argument but the description is supplied in the third argument instead of via a key.

    \longnewglossaryentry{〈label〉}
    {
      name={〈name〉},
      〈other options〉
    }
    {〈description〉}

Examples:

1. 1.Define the term “set” with the label `set`:

       🖹\newglossaryentry{set}
       {
         name={set},
         description={a collection of objects}
       }

2. 2.Define the symbol \(\emptyset \) with the label `emptyset`:

       🖹\newglossaryentry{emptyset}
       {
         name={\ensuremath{\emptyset}},
         description={the empty set}
       }

   (This will also need a sort key if you use Options 1 or 3, see below.)

3. 3.Define the phrase “Fish Age” with the label `fishage`:

       🖹\longnewglossaryentry{fishage}
       {name={Fish Age}}
       {%
         A common name for the Devonian geologic period
         spanning from the end of the Silurian Period to
         the beginning of the Carboniferous Period.

         This age was known for its remarkable variety of
         fish species.
       }

   (The percent character discards the end of line character that would otherwise cause an unwanted space to appear at the start of the description.)

4. 4.If you are using UTF-8 characters with the inputenc package, make sure you have mfirstuc v2.08+ installed:

       🖹% mfirstuc v2.08+
       \newglossaryentry{élite}
       {
         name={élite},
         description={select group or class}
       }

   If you have an older version of mfirstuc then any initial character that is an extended Latin or non-Latin character must be grouped in order to work with sentence-casing commands, such as `\Gls`. An older version possibly also means there may not be support for UTF-8 characters in labels either:

       🖹% mfirstuc v2.07 or older
       \newglossaryentry{elite}
       {
         name={{é}lite},
         description={select group or class}
       }

   Likewise if accent commands are used:

       🖹\newglossaryentry{elite}
       {
         name={{\'e}lite},
         description={select group or class}
       }

If you use bib2gls with glossaries-extra then the terms must be defined in a bib file. For example:

    🖹% Encoding: UTF-8

    @entry{set,
      name={set},
      description={a collection of objects}
    }

    @entry{emptyset,
      name={\ensuremath{\emptyset}},
      description={the empty set}
    }

    @entry{fishage,
      name={Fish Age},
      description={A common name for the Devonian
      geologic period spanning from the end of the
      Silurian Period to the beginning of the
      Carboniferous Period.

      This age was known for its remarkable variety of
      fish species.}
    }

    @entry{élite,
      name={élite},
      description={select group or class}
    }

(The bib format doesn’t allow spaces in labels so you can’t have `fish age` as the label, but you can have `fish-age`.) This method requires glossaries-extra’s record package option:

    🖹\usepackage[record]{glossaries-extra}

The bib file is specified in the resource command. For example, if the bib file is called entries.bib then put the following line in the document preamble:

    🖹\GlsXtrLoadResources[src={entries}]

You can have a comma-separated list. For example, if you also have entries defined in the file entries2.bib:

    🖹\GlsXtrLoadResources[src={entries,entries2}]

There are other keys you can use when you define an entry. For example, the name key indicates how the term should appear in the list of entries (glossary), but if the term should appear differently when you reference it with ``\gls`{〈label〉}` in the document, you need to use the text key as well.

For example:

    🖹\newglossaryentry{latinalph}
    {
      name={alphabet, Latin},
      text={Latin alphabet},
      description={alphabet consisting of the letters
      a, \ldots, z, A, \ldots, Z}
    }

This will appear in the text as “Latin alphabet” but will be listed in the glossary as “alphabet, Latin” (and therefore sorted under “A” not “L”). With bib2gls this entry is defined in the bib file as:

    🖹@entry{latinalph,
      name={alphabet, Latin},
      text={Latin alphabet},
      description={alphabet consisting of the letters
      a, \ldots, z, A, \ldots, Z}
    }

Another commonly used key is plural for specifying the plural of the term. This defaults to the value of the text key with an “s” appended, but if this is incorrect, just use the plural key to override it:

    🖹\newglossaryentry{oesophagus}
    {
      name={œsophagus},
      plural={œsophagi},
      description={canal from mouth to stomach}
    }

Abbreviations can be defined using:

📌
``\newacronym`[〈options〉]{〈label〉}{〈short〉}{〈long〉}`
where 〈label〉 is the label (as per `\newglossaryentry`), 〈short〉 is the short form and 〈long〉 is the long form. For example, the following defines an abbreviation:

    🖹\newacronym{svm}{SVM}{support vector machine}

This internally uses `\newglossaryentry` to define an entry with the label `svm`. By default, the name key is set to 〈short〉 (“SVM” in the above example) and the description key is set to 〈long〉 (“support vector machine” in the above example). If, instead, you want to be able to specify your own description you can do this using the optional argument:

    🖹\newacronym
     [description={statistical pattern recognition
     technique}]
     {svm}{SVM}{support vector machine}

Before you define your acronyms, you need to specify which style to use with:

📌
``\setacronymstyle`[〈glossary-type〉]{〈style-name〉}`
where 〈style-name〉 is the name of the style. There are a number of predefined styles, such as: long-short (on first use display the long form with the short form in parentheses); short-long (on first use display the short form with the long form in parentheses); long-short-desc (like long-short but you need to specify the description); or short-long-desc (like short-long but you need to specify the description). There are some other styles as well that use `\textsc` to typeset the acronym in small-caps or that use a footnote on first use. See the main user guide for further details.

The glossaries-extra package provides improved abbreviation handling with a lot more predefined styles. With this extension package, abbreviations are defined using:

📌
``\newabbreviation`[〈options〉]{〈label〉}{〈short〉}{〈long〉}`
You can still use `\newacronym` but it’s redefined to use the new abbreviation interface. The style must now be set using:
📌
``\setabbreviationstyle`[〈category〉]{〈style-name〉}`
The default 〈category〉 is abbreviation. If you use `\newacronym` the category is acronym, which is why you need to use the optional argument if you define abbreviations with `\newacronym` when glossaries-extra has been loaded:

    \setabbreviationstyle[acronym]{〈style name〉}

If you use bib2gls then abbreviations are defined in the bib file in the format:

    @abbreviation{〈label〉,
      long={〈long form〉},
      short={〈short form〉}
    }

The plural forms for abbreviations can be specified using the longplural and shortplural keys. For example:

    🖹\newacronym
     [longplural={diagonal matrices}]
     {dm}{DM}{diagonal matrix}

or (with glossaries-extra):

    🖹\newabbreviation % glossaries-extra.sty
     [longplural={diagonal matrices}]
     {dm}{DM}{diagonal matrix}

If omitted, the defaults are again obtained by appending an “s” to the singular versions. (The glossaries-extra package provides a way of not appending “s” for abbreviation plurals via category attributes.) With bib2gls, the definition in the bib file is:

    🖹@abbreviation{dm,
      short={DM},
      long={diagonal matrix},
      longplural={diagonal matrices}
    }

It’s also possible to have both a name and a corresponding symbol. Just use the name key for the name and the symbol key for the symbol. For example:

    🖹\newglossaryentry{emptyset}
    {
      name={empty set},
      symbol={\ensuremath{\emptyset}},
      description={the set containing no elements}
    }

or with bib2gls the definition in the bib file is:

    🖹@entry{emptyset,
      name={empty set},
      symbol={\ensuremath{\emptyset}},
      description={the set containing no elements}
    }

If you want commands such as `\emptyset` in the name field then you must supply a sort value with Options 1 and 3 otherwise you’ll end up with errors from TeX or xindy. With Option 2 (makeindex) you’re unlikely to get an error, but you may find the resulting order is a little odd. For example:

    🖹\newglossaryentry{emptyset}
    {
      name={\ensuremath{\emptyset}},
      sort={empty set},
      description={the set containing no elements}
    }

This displays the symbol as \(\emptyset \) but sorts according to “empty set”. You may want to consider using glossaries-extra’s symbols package option which provides
📌
``\glsxtrnewsymbol`[〈key=value list〉]{〈label〉}{〈sym〉}`

requires ``\usepackage`[symbols]{glossaries-extra}`
This internally uses `\newglossaryentry` but automatically sets the sort key to the 〈label〉. For example:

    🖹\documentclass{article}
    \usepackage[symbols]{glossaries-extra}
    \makeglossaries
    \glsxtrnewsymbol
     [description={the set containing no elements}]
     {emptyset}% label (and sort value)
     {\ensuremath{\emptyset}}% symbol
    \begin{document}
    \gls{emptyset}
    \printglossaries
    \end{document}

Now the sort value is automatically set to the label “emptyset”.

With bib2gls you can define this entry in the bib file as

    🖹@entry{emptyset,
      name={\ensuremath{\emptyset}},
      description={the set containing no elements}
    }

in which case bib2gls will try to interpret the name field to determine the sort value. Alternatively you can use:

    🖹@symbol{emptyset,
      name={\ensuremath{\emptyset}},
      description={the set containing no elements}
    }

which will use the label (`emptyset`) as the sort value. (You don’t need the symbols package option in this case, unless you want a separate symbols list.) The corresponding document (where the definition is in the file entries.bib) is now:

    🖹\documentclass{article}
    \usepackage[record]{glossaries-extra}
    \GlsXtrLoadResources[src={entries}]
    \begin{document}
    \gls{emptyset}
    \printunsrtglossaries
    \end{document}

Note that, while the sort key is advised for symbols when using `\makeglossaries` or `\makenoidxglossaries`, the sort field shouldn’t be used with bib2gls. Instead, bib2gls has its own algorithm for determining the sort value based on the entry type (`@entry`, `@symbol` etc) and various settings. See bib2gls gallery: sorting for further details.

[top]

## 3. Using Entries[link]

Once you have defined your entries, as described above, you can reference them in your document. There are a number of commands to do this, but the most common one is:

📌
``\gls`[〈options〉]{〈label〉}[〈insert〉]`modifiers: * +
where 〈label〉 is the label you assigned to the entry when you defined it. For example, ``\gls`{fishage}` will display “Fish Age” in the text (given the definition from the previous section). If you are using bib2gls then this will display `??` (like `\ref` and `\cite`) until bib2gls has created the relevant files and LaTeX is rerun.

If you are using the hyperref package (remember to load it before glossaries) `\gls` will create a hyperlink to the corresponding entry in the glossary. If you want to suppress the hyperlink for a particular instance, use the starred form ``\gls`*` for example, ``\gls`*{fishage}`. The other commands described in this section all have a similar starred form.

If the entry was defined as an acronym (using `\newacronym` with glossaries described above) or an abbreviation (using `\newabbreviation` with glossaries-extra), then `\gls` will display the full form the first time it’s used (first use) and just the short form on subsequent use. For example, if the style is set to long-short, then ``\gls`{svm}` will display “support vector machine (SVM)” the first time it’s used, but the next occurrence of ``\gls`{svm}` will just display “SVM”. (If you use `\newacronym` with glossaries-extra the default doesn’t show the long form on first use. You’ll need to change the style first, as described earlier.)

If you want the plural form, you can use:

📌
``\glspl`[〈options〉]{〈label〉}[〈insert〉]`modifiers: * +
instead of ``\gls`{〈label〉}`. For example, ``\glspl`{set}` displays “sets”.

If the term appears at the start of a sentence, you can convert the first letter to uppercase (sentence case) using:

📌
``\Gls`[〈options〉]{〈label〉}[〈insert〉]`modifiers: * +
for the singular form or
📌
``\Glspl`[〈options〉]{〈label〉}[〈insert〉]`modifiers: * +
for the plural form. For example:

    🖹\Glspl{set} are collections.

produces “Sets are collections”.

If you’ve specified a symbol using the symbol key, you can display it using:

📌
``\glssymbol`[〈options〉]{〈label〉}[〈insert〉]`modifiers: * +
For example

    🖹\documentclass{article}
    \usepackage{glossaries}
    \newglossaryentry{emptyset}
    {
      name={empty set},
      symbol={\ensuremath{\emptyset}},
      description={the set containing no elements}
    }
    \begin{document}
    The \gls{emptyset} is denoted \glssymbol{emptyset}.
    \end{document}

🖺
The empty set is denoted \(\emptyset \).

[top]

## 4. Displaying a List of Entries[link]

In §1, I mentioned that there are three options you can choose from to create an automatically sorted glossary with the base glossaries package. These are also available with the extension package glossaries-extra along with a fourth option. These four options are listed below in a little more detail. Table 1 summarises the main advantages and disadvantages. (There’s a more detailed summary in the main glossaries user manual.) See also Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.

Note that makeindex, upmendex and xindy are general purpose indexing applications that are developed independently of glossaries and glossaries-extra. This makes them harder to integrate, as glossaries have more complex requirements than a simple index, particularly for documents where some terms may only appear in the description of another term. (There’s also the possibility that they may change in a manner that becomes incompatible with glossaries or may even be declared obsolete.) The bib2gls application, on the other hand, is designed specifically for, and developed alongside, the glossaries-extra package.

Table 1: Comparison of Glossary Options

| Option 1 | Option 2 | Option 3 | Option 4
Requires glossaries-extra? | ✖ | ✖ | ✖ | ✔
Requires an external application? | ✖ | ✔ | ✔ | ✔
Requires Perl? | ✖ | ✖ | ✔ | ✖
Requires Java? | ✖ | ✖ | ✖ | ✔
Can sort extended Latin or non-Latin alphabets? | ✖∗ | ✖ | ✔ | ✔
Efficient sort algorithm? | ✖ | ✔ | ✔ | ✔
Can use different sort methods for each glossary? | ✔ | ✖ | ✖ | ✔
Any problematic sort values? | ✔ | ✔ | ✔ | ✖
Can form ranges in the location lists? | ✖ | ✔ | ✔ | ✔
Can have non-standard locations? | ✔ | ✖ | ✔† | ✔

∗Requires corresponding datatool v3.0+ localisation support.
†Requires some setting up.

Option 1 (“noidx”)

  This method works best with at least version 3.0 of the datatool-base package (which is supplied with datatool and automatically loaded by glossaries). If available, ensure that you have the applicable language support. (At the time of writing, only datatool-english is available.) Note that it does have limitations, such as no range formations in the location list and it can be slower than using an indexing application.

  If you have an old version of datatool, this method can be very slow and if you want a sorted list, it can be problematic with extended or non-Latin alphabets.

  For example, with datatool v3.0+ and datatool-english installed:

      🖹\usepackage[locales=en]{glossaries}

  or:

      🖹\usepackage[english]{babel}
      \usepackage{glossaries}

  1.Add `\makenoidxglossaries` to your preamble (before you start defining your entries, as described in §2).

  2.Put

      \printnoidxglossary[sort=〈order〉,〈other options〉]

  where you want your list of entries to appear. The sort 〈order〉 may be one of: `word` (word ordering), `letter` (letter ordering), `case` (case-sensitive ordering), `def` (in order of definition) or `use` (in order of use). Alternatively, use

      \printnoidxglossaries

  to display all your glossaries (if you have more than one).

  This option allows you to have different sort methods. For example:

      🖹\printnoidxglossary[sort=word]% main glossary
      \printnoidxglossary[
       type=symbols,% symbols glossary
       sort=use]

  3.Run LaTeX twice on your document. (As you would do to make a table of contents appear.) For example, click twice on the “typeset” or “build” or “PDFLaTeX” button in your editor.

  Here’s a complete document (myDoc.tex):

      🖹\documentclass{article}

      \usepackage{glossaries}

      \makenoidxglossaries% use TeX to sort

      \newglossaryentry{sample}{name={sample},
        description={an example}}

      \begin{document}
      A \gls{sample}.

      % iterate over all indexed entries:
      \printnoidxglossaries
      \end{document}

  Document build:

      〉_pdflatex myDoc
      pdflatex myDoc

Option 2 (makeindex/upmendex)

  This option uses an application called makeindex to sort the entries. This application comes with all modern TeX distributions, but it’s hard-coded for the non-extended Latin alphabet. This process involves making LaTeX write the glossary information to a temporary file which makeindex reads. Then makeindex writes a new file containing the code to typeset the glossary. LaTeX then reads this file on the next run. The makeindex application is automatically invoked by the helper makeglossaries script, which works out all the appropriate settings from the aux file.

  1.If you have UTF-8 or a non-Latin alphabet, then use upmendex (a makeindex substitute) instead of makeindex. You can indicate this with the upmendex package option:

      \usepackage[upmendex]{glossaries}

  2.Add `\makeglossaries` to your preamble (before you start defining your entries).

  3.Put

      \printglossary[〈options〉]

  where you want your list of entries (glossary) to appear. (The sort key isn’t available in 〈options〉.) Alternatively, use

      \printglossaries

  which will display all glossaries (if you have more than one).

  ℹ
  All glossaries are sorted using the same method which may be identified with one of the package options: sort=standard (default), sort=use or sort=def.

  4.Run LaTeX on your document. This creates files with the extensions glo and ist (for example, if your LaTeX document is called myDoc.tex, then you’ll have two extra files called myDoc.glo and myDoc.ist). If you look at your document at this point, you won’t see the glossary as it hasn’t been created yet.

  5.Run makeglossaries with the base name of your document (without the tex extension). If you have access to a terminal or a command prompt then you need to run the command:

      〉_makeglossaries myDoc

  (Replace myDoc with the base name of your LaTeX document file without the extension.) If you don’t have Perl installed use makeglossaries-lite instead:

      〉_makeglossaries-lite myDoc

  ℹ
  Some beginners get confused by makeglossaries the application (run as a system command) and `\makeglossaries` the LaTeX command which should be typed in the document preamble. These are two different concepts that happen to have similar looking names.

  If you don’t know how to use the command prompt, then you can probably configure your text editor to add makeglossaries (or makeglossaries-lite) as a build tool, but each editor has a different method of doing this, so I can’t give a general description. However, there are some guidelines in Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build. If you still have problems, try adding the automake package option:

      \usepackage[automake]{glossaries}

  The default sort is word order (“sea lion” comes before “seal”). If you want letter ordering you need to add the order=letter package option

      \usepackage[order=letter]{glossaries}

  6.Once you have successfully completed the previous step, you can now run LaTeX on your document again.

  Here’s a complete document (myDoc.tex):

      🖹\documentclass{article}

      \usepackage[
         % add upmendex for UTF-8 support
       ]{glossaries}

      \makeglossaries % create makeindex files

      \newglossaryentry{sample}{name={sample},
        description={an example}}

      \begin{document}
      A \gls{sample}.

      % input files created by makeindex/upmendex:
      \printglossaries
      \end{document}

  Document build:

      〉_pdflatex myDoc
      makeglossaries myDoc
      pdflatex myDoc

  or

      〉_pdflatex myDoc
      makeglossaries-lite myDoc
      pdflatex myDoc

Option 3 (xindy)

  This option uses an application called xindy to sort the entries. This application is more flexible than makeindex and is able to sort extended Latin or non-Latin alphabets. It comes with both TeX Live and MiKTeX. Since xindy is a Perl script, you will also need to ensure that Perl is installed. In a similar way to Option 2, this option involves making LaTeX write the glossary information to a temporary file which xindy reads. Then xindy writes a new file containing the code to typeset the glossary. LaTeX then reads this file on the next run. The xindy application is automatically invoked by the helper makeglossaries script, which works out all the appropriate settings from the aux file. See http://www.xindy.org/ for further information about xindy and links to its mailing list and issue tracker.

  1.Add the xindy option to the glossaries package option list:

      \usepackage[xindy]{glossaries}

  If you aren’t using a Latin script, you may need to suppress the default number group:

      \usepackage[xindy={glsnumbers=false}]{glossaries}

  2.Add `\makeglossaries` to your preamble (before you start defining your entries).

  3.Put

      \printglossary[〈options〉]

  where you want your list of entries (glossary) to appear. (The sort key isn’t available in 〈options〉.) Alternatively, use

      \printglossaries

  ℹ
  All glossaries are sorted using the same method which may be identified with one of the package options: sort=standard (default), sort=use or sort=def.

  4.Run LaTeX on your document. This creates files with the extensions glo and xdy (for example, if your LaTeX document is called myDoc.tex, then you’ll have two extra files called myDoc.glo and myDoc.xdy). If you look at your document at this point, you won’t see the glossary as it hasn’t been created yet.

  5.Run makeglossaries with the base name of the document (omitting the tex extension). If you have access to a terminal or a command prompt then you need to run the command:

      〉_makeglossaries myDoc

  (Replace myDoc with the base name of your LaTeX document file without the tex extension.) If you don’t know how to use the command prompt, then as mentioned above, you may be able to configure your text editor to add makeglossaries as a build tool. Note that the automake option won’t work in TeX’s restricted mode, as xindy isn’t on the list of trusted applications.

  The default sort is word order (“sea lion” comes before “seal”). If you want letter ordering you need to add the order=letter package option:

      \usepackage[xindy,order=letter]{glossaries}

  6.Once you have successfully completed the previous step, you can now run LaTeX on your document again.

  Here’s a complete document (myDoc.tex):

      🖹\documentclass{article}

      \usepackage[xindy]{glossaries}

      \makeglossaries % create xindy files

      \newglossaryentry{sample}{name={sample},
        description={an example}}

      \begin{document}
      A \gls{sample}.

      \printglossaries % input files created by xindy
      \end{document}

  Document build:

      〉_pdflatex myDoc
      makeglossaries myDoc
      pdflatex myDoc

  If you use xindy and the name only contains a command or commands (such as `\P` or `\ensuremath{\pi}`) you must add the sort key. This is also advisable for the other options (except Option 4, which, in general, shouldn’t have the sort field set), but is essential for Option 3. For example:

      🖹\newglossaryentry{P}{name={\P},sort={P},
        description={paragraph symbol}}

Option 4 (bib2gls)

  This requires the extension package glossaries-extra and an application called bib2gls. This application is able to sort extended Latin or non-Latin alphabets. It comes with both TeX Live and MiKTeX but requires Java. This method works differently to Options 2 and 3. Instead of creating a file containing the code to typeset the glossary it creates a glstex file containing the entry definitions obtained from data that was fetched from the bib file (or files), but only those entries that are required in the document are defined and they are defined in the order obtained from the chosen sort method. This means that you can just use `\printunsrtglossary` to display each glossary (or `\printunsrtglossaries` to display them all).

  1.Add the record option to the glossaries-extra package option list:

      \usepackage[record]{glossaries-extra}

  2.Add one or more

      \GlsXtrLoadResources[src={〈bib list〉},〈options〉]

  to your preamble where 〈bib list〉 is the list of bib files containing the entries. You may use different sort methods for each resource set. For example:

      🖹\usepackage[record,% using bib2gls
       abbreviations,% create abbreviations list
       symbols,% create symbols list
       numbers% create numbers list
      ]{glossaries-extra}

      \GlsXtrLoadResources[
        src={terms},% entries in terms.bib
      % put these entries in the 'main' list:
        type=main,
      % sort according to this locale:
        sort=de-CH-1996
      ]
      \GlsXtrLoadResources[
        src={abbrvs},% entries in abbrvs.bib
      % put these entries in the 'abbreviations' list:
        type={abbreviations},
      % case-sensitive letter (non-locale) sort:
        sort=letter-case
      ]
      \GlsXtrLoadResources[
        src={syms},% entries in syms.bib
      % put these entries in the 'symbols' list:
        type=symbols,
      % sort according to first use in the document:
        sort=use
      ]
      \GlsXtrLoadResources[
        src={constants},% entries in constants.bib
      % put these entries in the 'numbers' list:
        type=numbers,
      % sort according to the user1 field:
        sort-field=user1,
        sort=double% double-precision numeric sort
      ]

  The last resource set assumes that the entries defined in the file constants.bib have a number stored in the user1 field. For example:

      @number{pi,
        name={\ensuremath{\pi}},
        description={pi},
        user1={3.141592654}
      }

  3.Put

      \printunsrtglossary[type=〈type〉,〈options〉]

  where you want your list of entries (glossary) to appear. (The sort key isn’t available in 〈options〉. The sort setting needs to be used in `\GlsXtrLoadResources` instead.) Alternatively, use

      \printunsrtglossaries

  which will display all glossaries (if you have more than one).

  4.Run LaTeX on your document. The record option adds information to the aux file that provides bib2gls with all required details for each resource set. For example, if the file is called myDoc.tex:

      〉_pdflatex myDoc

  5.Run bib2gls

      〉_bib2gls myDoc

  or (if you need letter groups)

      〉_bib2gls --group myDoc

  6.Run LaTeX again.

  Here’s a complete document (myDoc.tex) with only one resource set for brevity:

      🖹\documentclass{article}

      \usepackage[record]{glossaries-extra}
      % input the glstex file created by bib2gls:
      \GlsXtrLoadResources
       [% instructions to bib2gls:
         src={entries}, % data in entries.bib
         sort=en-GB% sort according to this locale
       ]

      \begin{document}
      A \gls{sample}.

      % iterate over all defined entries:
      \printunsrtglossaries
      \end{document}

  The accompanying entries.bib file:

      @entry{sample,
        name={sample},
        description={an example}
      }

  Document build:

      〉_pdflatex myDoc
      bib2gls myDoc
      pdflatex myDoc

If you are having difficulty integrating makeglossaries (or makeglossaries-lite) or bib2gls into your document build process, you may want to consider using arara, which is a Java application that searches the document for special comment lines that tell arara which applications to run. For example, the file myDoc.tex might start with:

    🖹% arara: pdflatex
    % arara: makeglossaries
    % arara: pdflatex
    \documentclass{article}
    \usepackage{glossaries}
    \makeglossaries

then to build the document you just need the single system call:

    〉_arara myDoc

Alternatively, if you want to use makeglossaries-lite, change the second line to:

    % arara: makeglossarieslite

There’s also a rule for bib2gls. For example, the following indicates that letter groups are required:

    🖹% arara: pdflatex
    % arara: bib2gls: { group: on }
    % arara: pdflatex
    \documentclass{article}
    \usepackage[record]{glossaries-extra}
    \GlsXtrLoadResources

[top]

## 5. Customising the Glossary[link]

The default glossary style uses the description environment to display the entry list. Each entry name is set in the optional argument of `\item` which means that it will typically be displayed in bold. You can switch to medium weight by redefining `\glsnamefont`:

    🖹\renewcommand*{\glsnamefont}[1]{\textmd{#1}}

Some classes and packages redefine the description environment in such as way that’s incompatible with the glossaries package. In which case you’ll need to select a different glossary style (see below).

By default, a full stop is appended to the description (unless you use glossaries-extra). To prevent this from happening use the nopostdot package option:

    🖹\usepackage[nopostdot]{glossaries}

or to add it with glossaries-extra:

    🖹\usepackage[postdot]{glossaries-extra}

By default, a location list is displayed for each entry (except when `\printunsrtglossary` is used without bib2gls). This refers to the document locations (for example, the page number) where the entry has been referenced. If you use Options 2 or 3 described in §4 or Option 4 (with bib2gls and glossaries-extra) then location ranges will be compressed. For example, if an entry was used on pages 1, 2 and 3, then with Options 2, 3 or 4 the location list will appear as 1–3, but with Option 1 it will appear as 1, 2, 3. If you don’t want the locations displayed you can hide them using the nonumberlist package option:

    🖹\usepackage[nonumberlist]{glossaries}

or with bib2gls use save-locations=false in the optional argument of the appropriate `\GlsXtrLoadResources` (it’s possible to have some resource sets with locations and some without).

Entries are grouped according to the first letter of each entry’s sort value. By default a vertical gap is placed between letter groups for most of the predefined styles. You can suppress this with the nogroupskip package option:

    🖹\usepackage[nogroupskip]{glossaries}

If the default style doesn’t suit your document, you can change the style using:

📌
``\setglossarystyle`{〈style name〉}`
There are a number of predefined styles. Glossaries can vary from a list of symbols with a terse description to a list of words or phrases with descriptions that span multiple paragraphs, so there’s no “one style fits all” solution. You need to choose a style that suits your document. For example:

    🖹\setglossarystyle{index}

You can also use the style package option for the preloaded styles. For example:

    🖹\usepackage[style=index]{glossaries}

Examples:

1. 1.You have entries where the name is a symbol and the description is a brief phrase or short sentence. Try one of the “mcol” styles defined in the glossary-mcols package. For example:

       🖹\usepackage[nopostdot]{glossaries}
       \usepackage{glossary-mcols}
       \setglossarystyle{mcolindex}

   or

       🖹\usepackage[stylemods=mcols,style=mcolindex]{glossaries-extra}

2. 2.You have entries where the name is a word or phrase and the description spans multiple paragraphs. Try one of the “altlist” styles. For example:

       🖹\usepackage[nopostdot]{glossaries}
       \setglossarystyle{altlist}

   or

       🖹\usepackage[stylemods,style=altlist]{glossaries-extra}

3. 3.You have entries where the name is a single word, the description is brief, and an associated symbol has been set. Use one of the styles that display the symbol (not all of them do). For example, one of the tabular styles:

       🖹\usepackage[nopostdot,nonumberlist,
        style=long4col]{glossaries}

   or one of the “tree” styles:

       🖹\usepackage[nopostdot,nonumberlist,style=tree]{glossaries}

If your glossary consists of a list of abbreviations and you also want to specify a description as well as the long form, then you need to use an abbreviation style that will suit the glossary style. For example, use the long-short-desc acronym style:

    🖹\setacronymstyle{long-short-desc}

Define the acronyms with a description:

    🖹\newacronym
     [description={statistical pattern
       recognition technique}]
     {svm}{SVM}{support vector machine}

Alternatively with glossaries-extra:

    🖹\setabbreviationstyle{long-short-desc}

    \newabbreviation
     [description={statistical pattern
        recognition technique}]
     {svm}{SVM}{support vector machine}

Choose a glossary style that suits wide entry names. For example:

    🖹\setglossarystyle{altlist}

[top]

## 6. Multiple Glossaries[link]

The glossaries package predefines a default `main` glossary. When you define an entry (using one of the commands described in §2), that entry is automatically assigned to the default glossary, unless you indicate otherwise using the type key. However you first need to make sure the desired glossary has been defined. This is done using:

📌
``\newglossary`[〈log-ext〉]{〈glossary-label〉}{〈out-ext〉}{〈in-ext〉}{〈title〉}`
The 〈glossary-label〉 is a label that uniquely identifies this new glossary. As with other types of identifying labels, be careful not to use active characters in 〈label〉. The final argument 〈title〉 is the section or chapter title used by `\printglossary`, `\printnoidxglossary` or `\printunsrtglossary`. The other arguments indicate the file extensions used by makeindex/upmendex or xindy (described in §4). If you’re not using makeindex, upmendex or xindy, then the 〈log-ext〉, 〈in-ext〉 and 〈out-ext〉 arguments aren’t relevant, in which case you may prefer to use the starred version where those arguments are omitted:
📌
``\newglossary*`{〈glossary-label〉}{〈title〉}`

In the case of Options 2 or 3, all new glossaries must be defined before `\makeglossaries`. (Entry definitions should come after `\makeglossaries`.) In the case of Option 4, all new glossaries must be defined before any `\GlsXtrLoadResources` that requires them.

Since it’s quite common for documents to have both a list of terms and a list of abbreviations, the glossaries package provides the package option acronyms (or acronym), which is a convenient shortcut for

    \newglossary[alg]{acronym}{acr}{acn}{\acronymname}

The option also changes the behaviour of `\newacronym` so that acronyms are automatically put in the list of acronyms instead of the main glossary. The glossaries-extra package also supports the acronyms option for abbreviations defined using `\newacronym` but additionally has the package option abbreviations to create a list of abbreviations for `\newabbreviation`.

There are some other package options for creating commonly used lists: symbols (lists of symbols), numbers (lists of numbers), index (an index). Since indexes don’t typically have descriptions, the index option also defines:

📌
``\newterm`[〈key=value list〉]{〈entry-label〉}`

requires index package option
This is just a shortcut that uses `\newglossaryentry` with the name set to 〈entry-label〉 and the description is suppressed.

For example, suppose you want a main glossary for terms, a list of acronyms and a list of notation:

    🖹\usepackage[acronyms]{glossaries}
    \newglossary[nlg]{notation}{not}{ntn}{Notation}

After `\makeglossaries` (or `\makenoidxglossaries`) you can define the entries in the preamble. For example:

    🖹\newglossaryentry{gls:set}
    {% This entry goes in the `main' glossary
      name={set},
      description={A collection of distinct objects}
    }

    % This entry goes in the `acronym' glossary:
    \newacronym{svm}{svm}{support vector machine}

    \newglossaryentry{not:set}
    {% This entry goes in the `notation' glossary:
      type={notation},
      name={\ensuremath{\mathcal{S}}},
      description={A set},
      sort={S}}

or if you don’t like using `\ensuremath`:

    🖹\newglossaryentry{not:set}
    {% This entry goes in the `notation' glossary:
      type={notation},
      name={$\mathcal{S}$},
      text={\mathcal{S}},
      description={A set},
      sort={S}
    }

Each glossary is displayed using:

    \printnoidxglossary[type=〈type〉]

(Option 1) or

    \printglossary[type=〈type〉]

(Options 2 and 3). Where 〈type〉 is the glossary label. If the type is omitted the default `main` glossary is assumed.

If you’re using bib2gls then each glossary is displayed using:

    \printunsrtglossary[type=〈type〉]

With this method you don’t use `\makeglossaries` or `\makenoidxglossaries`. Instead you can assign the entry type with the resource command. For example:

    🖹\usepackage[record,abbreviations,symbols]{glossaries-extra}

    \GlsXtrLoadResources[
     src={terms}, % entries defined in terms.bib
     type=main% put in main glossary
    ]
    \GlsXtrLoadResources[
     src={abbrvs}, % entries defined in abbrvs.bib
     type=abbreviations% put in abbreviations glossary
    ]
    \GlsXtrLoadResources[
     src={syms}, % entries defined in syms.bib
     type=symbols% put in symbols glossary
    ]

Later in the document:

    🖹\printunsrtglossary % main
    \printunsrtglossary[type=abbreviations]
    \printunsrtglossary[type=symbols]

There’s a convenient shortcut that will display all the defined glossaries depending on the indexing method:

📌
``\printnoidxglossaries``
(Option 1) or
📌
``\printglossaries``
(Options 2 and 3) or (glossaries-extra only)
📌
``\printunsrtglossaries``

If you use Options 1 or 4, you don’t need to do anything different for a document with multiple glossaries. If you use Options 2 or 3 with the makeglossaries Perl script or the makeglossaries-lite Lua script, you similarly don’t need to do anything different to the document build (compared to building a document with only one glossary).

If you use Options 2 or 3 without the helper makeglossaries Perl script or makeglossaries-lite Lua script then you need to make sure you run makeindex/upmendex or xindy for each defined glossary. The 〈gls〉 and 〈glo〉 arguments of `\newglossary` specify the file extensions to use instead of gls and glo. The optional argument 〈glg〉 is the file extension for the transcript file. This should be different for each glossary in case you need to check for makeindex/upmendex/xindy errors or warnings if things go wrong.

For example, suppose you have three glossaries in your document (`main`, `acronym` and `notation`), specified using:

    🖹\usepackage[acronyms]{glossaries}
    \newglossary[nlg]{notation}{not}{ntn}{Notation}

Then (assuming your LaTeX document is in a file called myDoc.tex):

Option 2: Either use one makeglossaries or makeglossaries-lite call:

    〉_makeglossaries myDoc

or

    〉_makeglossaries-lite myDoc

Or you need to run makeindex three times:

    〉_makeindex -t myDoc.glg -s myDoc.ist -o myDoc.gls myDoc.glo
    makeindex -t myDoc.alg -s myDoc.ist -o myDoc.acr myDoc.acn
    makeindex -t myDoc.nlg -s myDoc.ist -o myDoc.not myDoc.ntn

Or if you are using upmendex:

    〉_upmendex -t myDoc.glg -s myDoc.ist -o myDoc.gls myDoc.glo
    upmendex -t myDoc.alg -s myDoc.ist -o myDoc.acr myDoc.acn
    upmendex -t myDoc.nlg -s myDoc.ist -o myDoc.not myDoc.ntn

Option 3: Either use one makeglossaries call:

    〉_makeglossaries myDoc

Or you need to run xindy three times (be careful not to insert line breaks where the line has wrapped.)

    〉_xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.glg -o myDoc.gls myDoc.glo
    xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.alg -o myDoc.acr myDoc.acn
    xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.nlg -o myDoc.not myDoc.ntn

Option 4: With bib2gls only one call is required:

    〉_pdflatex myDoc
    bib2gls --group myDoc
    pdflatex myDoc

(Omit --group if you don’t need letter groups.)

[top]

## 7. Hyperlinks (glossaries and hyperref)[link]

Take care if you use the glossaries package with hyperref. Contrary to the usual advice that hyperref should be loaded last, glossaries (and glossaries-extra) must be loaded after hyperref:

    🖹\usepackage[colorlinks]{hyperref}
    \usepackage{glossaries}

By default, if the hyperref package has been loaded, commands like `\gls` will form a hyperlink to the relevant entry in the glossary. If you want to disable this for all your glossaries, then use:

📌
``\glsdisablehyper``
If you want hyperlinks suppressed for entries in specific glossaries, then use the nohypertypes package option. For example, if you don’t want hyperlinks for entries in the `acronym` and `notation` glossaries but you do want them for entries in the `main` glossary, then do:

    🖹\usepackage[colorlinks]{hyperref}
    \usepackage[acronym,nohypertypes={acronym,notation}]{glossaries}
    \newglossary[nlg]{notation}{not}{ntn}{Notation}

If you want the hyperlinks suppressed the first time an entry is used, but you want hyperlinks for subsequence references then use the hyperfirst=false package option:

    🖹\usepackage[colorlinks]{hyperref}
    \usepackage[hyperfirst=false]{glossaries}

The glossaries-extra extension package provides another method using category attributes. See the glossaries-extra user manual for further details.

Take care not to use non-expandable commands in PDF bookmarks. This isn’t specific to the glossaries package but is a limitation of PDF bookmarks. Non-expandable commands include commands like `\gls`, `\glspl`, `\Gls` and `\Glspl`. The hyperref package provides a way of specifying alternative text for the PDF bookmarks via `\texorpdfstring`. For example:

    🖹\section{The \texorpdfstring{\gls{fishage}}{Fish Age}}

However, it’s not a good idea to use commands like `\gls` in a section heading as you’ll end up with the table of contents page in your location list and it will unset the first use flag too soon. Instead you can use
📌
``\glsentrytext`{〈entry-label〉}`
This is expandable provided that the text key doesn’t contain non-expandable code. For example, the following works:

    🖹\section{The \glsentrytext{fishage}}

and it doesn’t put the table of contents in the location list.

If you use glossaries-extra then use the commands that are provided specifically for use in section headers. For example:

    🖹\section{The \glsfmttext{fishage}}

[top]

## 8. Cross-References[link]

You can add a reference to another entry in a location list using the see={〈label-list〉} key when you define an entry. The referenced entry (or entries) must also be defined.

For example:

    🖹\longnewglossaryentry{devonian}{name={Devonian}}%
    {%
      The geologic period spanning from the end of the
      Silurian Period to the beginning of the
      Carboniferous Period.

      This age was known for its remarkable variety of
      fish species.
    }

    \newglossaryentry{fishage}
    {
      name={Fish Age},
      description={Common name for the Devonian period},
      see={devonian}
    }

The cross-reference will appear as “see Devonian”. You can change the “see” tag for an individual entry using the format see={[〈tag〉]〈label-list〉}. For example:

    🖹\newglossaryentry{latinalph}
    {
      name={Latin alphabet},
      description={alphabet consisting of the letters
      a, \ldots, z, A, \ldots, Z},
      see=[see also]{exlatinalph}
    }
    \newglossaryentry{exlatinalph}
    {
       name={extended Latin alphabet},
       description={The Latin alphabet
       extended to include other letters such as
       ligatures or diacritics.}
    }

In the above, I haven’t enclosed the entire value of the see key in braces. If you use the see key in an optional argument, such as the optional argument of `\newacronym`, make sure you enclose the value (including the optional tag) in braces. For example:

    🖹\newacronym{ksvm}{ksvm}{kernel support vector machine}
    \newacronym
     [see={[see also]{ksvm}}]
     {svm}{svm}{support vector machine}

The glossaries-extra package provides a seealso key. This doesn’t allow a tag but behaves much like see={[`\seealsoname`]{〈label-list〉}}. For example:

    🖹\newabbreviation{ksvm}{ksvm}
      {kernel support vector machine}
    \newabbreviation
     [seealso={ksvm}]
     {svm}{svm}{support vector machine}

Additionally, the glossaries-extra package provides an alias key where the value must be just a single label. See glossaries-extra gallery: aliases for an example.

Since the cross-reference appears in the location list, if you suppress the location list using the nonumberlist package option, then the cross-reference will also be suppressed. With bib2gls, don’t use the nonumberlist package option in this case, but instead use save-locations=false in the resource options. For example:

    🖹\usepackage[record,abbreviations,symbols]{glossaries-extra}

    \GlsXtrLoadResources[
     src={terms}, % entries defined in terms.bib
     type=main% put in main glossary
    ]
    \GlsXtrLoadResources[
     src={abbrvs}, % entries defined in abbrvs.bib
     type=abbreviations,% put in abbreviations glossary
    % no number list for these entries:
     save-locations=false
    ]
    \GlsXtrLoadResources[
     src={syms}, % entries defined in syms.bib
     type=symbols% put in symbols glossary
    ]

[top]

## 9. Further Information[link]

- •glossaries-extra and bib2gls: an introductory guide.
- •The main glossaries user manual.
- •The glossaries FAQ.
- •Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.
- •The glossaries-extra package.
- •The bib2gls application.

The Dickimaw Books Gallery provides additional example documents.

[top]

## Symbols[link]

📌
  The syntax and usage of a command, environment or option etc.
ℹ
  An important message.
🛈
  Prominent information.
🖹
  LaTeX code to insert into your document.
🖹🛇
  Problematic code which should be avoided.
🖺
  How the example code should appear in the PDF.
〉_
  A command-line application invocation that needs to be entered into a terminal or command prompt.

[top]

## Glossary[link]

First use
  The first time an entry is used by a command that unsets the first use flag (or the first time since the flag was reset).
First use flag
  A conditional that keeps track of whether or not an entry has been referenced by any of the `\gls`-like commands (which can adjust their behaviour according to whether or not this flag is true). The conditional is true if the entry hasn’t been used by one of these commands (or if the flag has been reset) and false if it has been used (or if the flag has been unset).
Glossary
  Technically a glossary is an alphabetical list of words relating to a particular topic. For the purposes of describing the glossaries and glossaries-extra packages, a glossary is either the list produced by commands like `\printglossary` or `\printunsrtglossary` (which may or may not be ordered alphabetically) or a glossary is a set of entry labels where the set is identified by the glossary label or type.
`\Gls`-like
  Commands like `\gls` that change the first use flag. These commands index the entry (if indexing is enabled), create a hyperlink to the entry’s glossary listing (if enabled) and unset the first use flag.
Indexing (or recording)
  The process of saving the location (for example, the page number) and any associated information that is required in the glossary. The data may be sorted and collated by an indexing application as part of the document build.
Link text
  The text produced by commands like `\gls` that have the potential to be a hyperlink.
Semantic command
  Essentially, a semantic command is one that’s associated with a particular document element, idea or topic that hides the font and other stylistic formatting inside its definition. For example, Latin taxonomy is usually displayed in italic. Explicitly using font commands, for example `\textit{Clostridium}`, is syntactic markup. Whereas defining a command called, say, `\bacteria` that displays its argument in italics is a semantic command. The actual styling is hidden and the command relates specifically to a particular concept.

      🖹Syntactic: \textit{Clostridium}
      \newrobustcmd*{\bacteria}[1]{\emph{#1}}%
      Semantic: \bacteria{Clostridium}

  The end result is the same:
  🖺
  Syntactic: Clostridium

  Semantic: Clostridium

  The advantage with semantic commands is that it’s much easier to change the style, simply by adjusting the command definition. Note that I’ve used `\newrobustcmd` to make the semantic command robust as the style commands can cause a problem if they expand too soon. Alternatively, use `\NewDocumentCommand`.
Subsequent use
  Using an entry that unsets the first use flag when it has already been unset.

[top]

## Command Summary[link]

[top]

### A[link]

`\acronymname`initial: Acronyms; glossaries

(language-sensitive)

Expands to the title of the `acronym` glossary.

[top]

### G[link]

`\Gls``[〈options〉]{〈label〉}[〈insert〉]`modifiers: * + glossaries

As `\gls` but converts the first character of the link text to uppercase (for the start of a sentence) using `\makefirstuc`. §3; 20

`\gls``[〈options〉]{〈label〉}[〈insert〉]`modifiers: * + glossaries

References the entry identified by 〈label〉. The text produced may vary depending on whether or not this is the first use. §3; 19

`\glsabbrvonlyfont``{〈text〉}`glossaries-extra v1.17+

Short form font used by the “only” abbreviation styles.

`\glsabbrvscfont``{〈text〉}`glossaries-extra v1.17+

Short form font used by the small-caps “sc” abbreviation styles.

`\glsdefaulttype`initial: main; glossaries

Expands to the label of the default glossary.

`\glsdisablehyper` glossaries

Suppresses all glossary related hyperlinks. §7; 41

`\glsentrylong``{〈entry-label〉}`glossaries

Simply expands to the value of the long field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the long field doesn’t contain any fragile commands.

`\glsentryshort``{〈entry-label〉}`glossaries

Simply expands to the value of the short field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the short field doesn’t contain any fragile commands.

`\glsentrytext``{〈entry-label〉}`glossaries

Simply expands to the value of the text field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the text field doesn’t contain any fragile commands. §7; 42

`\glsfmtshort``{〈entry-label〉}`

For use within captions or section titles to display the formatted short form.

`\glsfmttext``{〈entry-label〉}`

For use within captions or section titles to display the formatted text.

`\glslongonlyfont``{〈text〉}`glossaries-extra v1.17+

Long form font used by the “only” abbreviation styles.

`\glslowercase``{〈text〉}`glossaries v4.50+

Converts 〈text〉 to lowercase using the modern LaTeX3 case-changing command, which is expandable.

`\glsnamefont``{〈text〉}`glossaries

Used within the predefined glossary styles to apply a font change to the name.

`\glsnoexpandfields` glossaries

Don’t expand field values when defining entries, except for those that explicitly have expansion enabled.

`\Glspl``[〈options〉]{〈label〉}[〈insert〉]`modifiers: * + glossaries

As `\Gls` but uses the plural form. §3; 20

`\glspl``[〈options〉]{〈label〉}[〈insert〉]`modifiers: * + glossaries

As `\gls` but uses the plural form. §3; 20

`\GlsSetQuote``{〈character〉}`glossaries v4.24+

Set makeindex’s quote character to 〈character〉.

`\glssymbol``[〈options〉]{〈label〉}[〈insert〉]`modifiers: * +

References the entry identified by 〈label〉. The text produced is obtained from the symbol value. The 〈insert〉 argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. §3; 20

`\GlsXtrLoadResources``[〈options〉]`glossaries-extra v1.11+

For use with bib2gls, this both sets up the resource options (which bib2gls can detect from the aux file) and inputs the glstex file created by bib2gls.

`\glsxtrnewsymbol``[〈key=value list〉]{〈label〉}{〈sym〉}`glossaries-extra

(requires ``\usepackage`[symbols]{glossaries-extra}`)

Defines a new glossary entry with the given label, type set to `symbols`, the category set to `symbol`, the name set to 〈sym〉 and the sort set to 〈label〉. The optional argument is a comma-separated list of glossary entry keys, which can be used to override the defaults. §2; 18

[top]

### L[link]

`\loadglsentries``[〈type〉]{〈filename〉}`glossaries

Locally assigns `\glsdefaulttype` to 〈type〉 and inputs 〈filename〉. If the optional argument is omitted, the default glossary is assumed. Note that if any entries within 〈filename〉 have the type key set (including implicitly in commands like `\newacronym`), then this will override the type given in the optional argument.

`\longnewglossaryentry``{〈label〉}{〈key=value list〉}{〈description〉}`glossaries

Defines a new glossary entry with the given label. The second argument is a comma-separated list of glossary entry keys. The third argument is the description, which may include paragraph breaks. §2; 11

[top]

### M[link]

`\makefirstuc``{〈text〉}`mfirstuc

Robust command that converts the first character of 〈text〉 to uppercase (sentence case). See the mfirstuc documentation for further details, either:

    〉_texdoc mfirstuc

or visit ctan.org/pkg/mfirstuc.

`\makeglossaries` glossaries

Opens the associated glossary files that need to be processed by makeindex or xindy.

`\makenoidxglossaries` glossaries v4.04+

Sets up all glossaries so that they can be displayed with `\printnoidxglossary`.

[top]

### N[link]

`\newabbreviation``[〈options〉]{〈label〉}{〈short〉}{〈long〉}`glossaries-extra

Defines a new entry that represents an abbreviation. This internally uses `\newglossaryentry` and any provided 〈options〉 (glossary entry keys) will be appended. The category is set to abbreviation by default, but may be overridden in 〈options〉. The appropriate style should be set before the abbreviation is defined with `\setabbreviationstyle`. §2; 16

`\newacronym``[〈options〉]{〈label〉}{〈short〉}{〈long〉}`glossaries

This command is provided by the base glossaries package but is redefined by glossaries-extra to use `\newabbreviation` with the category key set to acronym. With just the base glossaries package, use `\setacronymstyle` to set the style. With glossaries-extra, use ``\setabbreviationstyle`[acronym]{〈style〉}` to set the style that governs `\newacronym`. §2; 15

`\newglossary``[〈log-ext〉]{〈glossary-label〉}{〈out-ext〉}{〈in-ext〉}{〈title〉}`glossaries

Defines a glossary identified by 〈glossary-label〉 (which can be referenced by the type key when defining an entry). §6; 36

`\newglossary*``{〈glossary-label〉}{〈title〉}`glossaries v4.08+

A shortcut that supplies file extensions based on the glossary label:

    \newglossary[〈glossary-label〉-glg]{〈glossary-label〉}{〈glossary-label〉-gls}{〈glossary-label〉-glo}{〈title〉}

§6; 36

`\newglossaryentry``{〈label〉}{〈key=value list〉}`glossaries

Defines a new glossary entry with the given label. The second argument is a comma-separated list of glossary entry keys. §2; 11

`\newterm``[〈key=value list〉]{〈entry-label〉}`

(requires index package option)

Defines a new glossary entry with the given label, type set to `index`, the name set to 〈entry-label〉 and the description set to `\nopostdesc`. The optional argument is a comma-separated list of glossary entry keys, which can be used to override the defaults. §6; 36

`\nopostdesc` glossaries v1.17+

When placed at the end of the description, this switches off the post-description punctuation (if it has been enabled). Does nothing outside of the glossary.

[top]

### P[link]

`\printglossaries` glossaries

Iterates over all glossaries and does ``\printglossary`[type=〈type〉]` for each glossary. §6; 39

`\printglossary``[〈options〉]`glossaries

Displays the glossary by inputting a file created by makeindex or xindy. Must be used with `\makeglossaries` and either makeindex or xindy.

`\printnoidxglossaries` glossaries v4.04+

Iterates over all glossaries and does ``\printnoidxglossary`[type=〈type〉]` for each glossary. §6; 39

`\printnoidxglossary``[〈options〉]`glossaries v4.04+

Displays the glossary by obtaining the indexing information from the aux file and using TeX to sort and collate. Must be used with `\makenoidxglossaries`. This method can be very slow and has limitations.

`\printunsrtglossaries` glossaries-extra v1.08+

Iterates over all glossaries and does ``\printunsrtglossary`[type=〈type〉]` for each glossary. §6; 39

`\printunsrtglossary``[〈options〉]`glossaries-extra v1.08+

Displays the glossary by iterating over all entries associated with the given glossary (in the order in which they were added to the glossary). The location lists and group headers will only be present if the associated fields have been set (typically by bib2gls).

[top]

### S[link]

`\seealsoname`initial: see also; glossaries-extra

(language-sensitive)

Used as a cross-reference tag.

`\setabbreviationstyle``[〈category〉]{〈style-name〉}`glossaries-extra

Sets the current abbreviation style to 〈style-name〉 for the category identified by 〈category〉. If the optional argument is omitted, abbreviation is assumed. §2; 16

`\setacronymstyle``[〈glossary-type〉]{〈style-name〉}`glossaries

Sets the acronym style. Don’t use with glossaries-extra. §2; 16

`\setglossarystyle``{〈style name〉}`glossaries

Set the current glossary style to 〈style name〉. §5; 33

[top]

## Index[link]

Symbols A B C D F G H I L M N O P R S T U X
[top]

### Symbols[link]

`:` (colon) 6, 7
`??` (unknown entry marker) 20
[top]

### A[link]

abbreviation styles 53,
see `\setabbreviationstyle`
long-short-sc 5
long-short 4, 5
short-nolong 5
abbreviations 29, 36, 38
acronym 36
acronym styles
see `\setacronymstyle`
long-sc-short 5
long-short-desc 16, 35
long-short 3, 4, 16, 20
short-long-desc 16
short-long 16
`\acronymname` 36, 46
acronyms 36
arara 32
automake 25, 27
[top]

### B[link]

babel package 2, 6, 7
bib2gls 5, 8, 10, 13, 15–17, 19–21, 28–30, 32, 33, 38, 40, 44, 49, 52
-g
see bib2gls▷--group
--group 31, 40
[top]

### C[link]

category
abbreviation 16, 50, 53
acronym 4, 16, 51
[top]

### D[link]

datatool-base package 9, 21
datatool-english 21, 22
datatool package Table 1; 9, 21, 22
description environment 32, 33
[top]

### F[link]

file formats
acn 36
acr 36
alg 36
aux 24, 26, 30, 52
bib 5, 13, 14, 29
glo 24, 27, 39
gls 39
glstex 29
ist 24
log 4
tex 5
xdy 27
first use 45
first use flag 45
fontenc package 2
[top]

### G[link]

glossaries-extra package 4, 28
glossaries-french 2
glossaries-german 2
glossaries-〈language〉 2
glossaries package 2
glossary-mcols package 34
glossary 45
glossary entry keys
alias 43
category 49–51
description 2, 3, 11, 16, 35, 37, 51
long 17, 47
longplural 17
name 2, 3, 11, 14, 16–19, 28, 37, 48, 49, 51
plural 10, 15
see 42, 43
seealso 43
short 17, 47, 48
shortplural 17
sort 12, 18, 19, 28, 33, 49
symbol 17, 20, 49
text 14, 15, 42, 48
type 36, 49–51
user1 30
glossary styles 53
altlist 34, 35
index 34
indexgroup 10
long4col 35
mcolindex 34
`\Gls` §3; 13, 20, 41, 47, 49
`\gls` §3; 2–9, 14, 19, 20, 41, 42, 45, 46, 47, 49
`\gls`-like 10, 45
`\glsabbrvonlyfont` 47
`\glsabbrvscfont` 47
`\glsdefaulttype` 47, 49
`\glsdisablehyper` §7; 41, 47
`\glsentrylong` 7, 47
`\glsentryshort` 7, 47
`\glsentrytext` §7; 7, 42, 48
`\glsfmtshort` 7, 48
`\glsfmttext` 7, 42, 48
`\glslongonlyfont` 48
`\glslowercase` 48
`\glsnamefont` 32, 48
`\glsnoexpandfields` 4, 48
`\Glspl` §3; 20, 41, 49
`\glspl` §3; 10, 20, 41, 49
`\GlsSetQuote` 49
`\glssymbol` §3; 20, 49
`\GlsXtrLoadResources` 8, 29, 30, 33, 36, 38, 49
save-locations 33, 44
sort-field 30
sort 29, 30
src 29, 30, 38
type 29, 30, 38
`\glsxtrnewsymbol` §2; 18, 49
[top]

### H[link]

hyperfirst 41
hyperref package 2, 7, 20, 41
[top]

### I[link]

index 36, 51
indexing (or recording) 8, 45, 52
inputenc package 2, 12
`\item` 32
[top]

### L[link]

link text 4, 46, 47, 49
`\loadglsentries` 5, 49
`\longnewglossaryentry` §2; 11, 50
lowercase 48
[top]

### M[link]

`\makefirstuc` 47, 50
`\makeglossaries` 19, 24, 25, 27, 36–38, 50, 52
makeglossaries-lite 25, 32, 39
makeglossaries 24–27, 32, 39, 40
makeindex 8, 10, 18, 21, 23, 24, 26, 36, 39, 49, 50, 52
`\makenoidxglossaries` 9, 19, 22, 37, 38, 50, 52
mfirstuc package 12, 13, 50
[top]

### N[link]

`\newabbreviation` §2; 4–6, 16, 20, 35, 36, 50, 51
`\newacronym` §2; 3–6, 15, 16, 20, 35, 36, 43, 50, 51
`\newglossary` §6; 36, 39, 51
`\newglossary*` §6; 36, 51
`\newglossaryentry` §2; 2–4, 6, 11, 15, 16, 18, 37, 50, 51
`\newterm` §6; 36, 51
nogroupskip 9, 33
nohypertypes 41
nonumberlist 10, 33, 44
`\nopostdesc` 51
nopostdot 10, 33
numbers 29, 36
[top]

### O[link]

Option 1 (“noidx”) Table 1; 8, 21, 33, 38, 39
Option 2 (makeindex/upmendex) Table 1; 8, 10, 18, 23, 26, 39
Option 3 (xindy) Table 1; 8, 10, 26, 28, 40
Option 4 (bib2gls) Table 1; 8, 10, 28, 33, 36, 40
order 25, 27
[top]

### P[link]

polyglossia package 2
postdot 10
print [unsrt|noidx] glossary options
sort 22, 24, 27, 30
type 30, 38, 52
`\printglossaries` §6; 24, 27, 39, 52
`\printglossary` 24, 27, 36, 38, 45, 52
`\printnoidxglossaries` §6; 9, 23, 39, 52
`\printnoidxglossary` 22, 36, 38, 50, 52
`\printunsrtglossaries` §6; 8, 29, 30, 39, 52
`\printunsrtglossary` 29, 30, 33, 36, 38, 45, 52
[top]

### R[link]

record 8, 14, 29, 30, 38
[top]

### S[link]

`\seealsoname` 43, 53
semantic command 4, 46
sentence case 20, 47, 50
`\setabbreviationstyle` §2; 4, 5, 16, 35, 50, 51, 53
`\setacronymstyle` §2; 3, 5, 16, 35, 51, 53
`\setglossarystyle` §5; 33, 34, 35, 53
sort 8, 24, 27
style 10, 34
stylemods 34
subsequent use 46
symbols 18, 19, 29, 36, 38, 49
[top]

### T[link]

`\texorpdfstring` 41
`\textsc` 5, 16
[top]

### U[link]

upmendex 8, 10, 21, 24, 36, 39, 40
upmendex 24
uppercase 20, 47, 50,
see also sentence case
[top]

### X[link]

xindy 8, 10, 18, 21, 26–28, 36, 39, 40, 50, 52
xindy 26