7
Glossaries

7.1 Introduction

A Glossary is an alphabetical list of terms in a particular domain of knowledge with the definitions for those terms. This is done to simplify typing and to reduce redundancies within the text. For example, let’s look at the following text:

…Partial Differential Equations are important equations to engineers with one of the most important Partial Differential Equation is the Heat Equation which is classified as a linear Partial Differential Equation …

As we can see there is a lot of redundancies which adds a lot of frivolous text which makes the text look more busy than it needs to be. With a glossary we can rewrite it as:

…Partial Differential Equations (PDEs) are important equations to engineers with one of the most important PDE is the Heat Equation which is classified as a linear PDE …

Which is clearly tidier and cleaner way of writing the text. Due to this, many technical documents use terms, acronyms, and symbols in their text. It is common practice to add a glossary to make such documents more accessible.

The glossaries package can be used to create glossaries. It supports multiple glossaries, acronyms, and symbols.

7.2 Using Glossaries

To use the glossaries package, you have to load it explicitly using usepackage{...} :

latex
\usepackage{glossaries}

If you would like to make sure your all the hyperlinks are working with your glossaries, make sure the glossaries is loaded before hyperref. Otherwise the glossary entries within the text will not be clickable.

For the glossary to show up in your Table of Contents , you need to specify the toc option when loading the packages such as:

latex
\usepackage[toc]{glossaries}

And of course, then we need to tell glossaries where to put all the glossary. To make this happen, place the following command in your document preamble in order to generate the glossary:

latex
\makeglossaries

In addition, If you would like to use makeglossaries you will need to have Perl 1 1 A general purpose programming language known for being the glue of the internet and having powerful text manipulation methods. installed on your computer which is not normally present by default on Microsoft Windows platforms.

The makeglossaries simply provides a convenient interface to makeindex and xindy and is NOT essential as one could use either of those commands/packages instead.

7.2.1 Defining a Glossary Entry

To use an entry from a glossary we first need to define it. There are few ways to define an entry depending on what you define and how it is going to be used.

A defined entry won’t be included in the printed glossary unless it is used in the document.

While this may sounds like an oversight, it is actually a feature as this enables us to create a glossary of general terms for multiple documents and the based on what is used in an individual document, only the ones used will be printed .

To define a term in glossary we use the \newglossaryentry macro:

latex
\newglossaryentry{<label>}{<settings>}

where <label> is a unique label used to identify an entry in glossary, and <settings> are comma separated key=value pairs used to define an entry. For example, to define a entry for the word computer :

latex
\newglossaryentry{computer} { name=computer, description={is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format} }

If we look at the example above, we have defined an entry which has the same label and entry name. This is not always have to be the case as the next entry will show where it is different:

latex
\newglossaryentry{naiive} { name=na\"{\i}ve, description={is a French loanword (adjective, form of naïf) indicating having or showing a lack of experience, understanding or sophistication} }

When you define terms, we need to remember these entries will be sorted by makeindex or xindy.

Therefore it’s needed to extend our example and specify how to sort the word:

latex
\newglossaryentry{naiive} { name=na\"{\i}ve, description={is a French loanword (adjective, form of naïf) indicating having or showing a lack of experience, understanding or sophistication}, sort=naiive }

Here we explicitly state that this entry should be sorted as naiive. We can also specify plural forms, if they are not formed by adding “s”: 2 2 Of course, for most applications it is just better to add a lowercase s to the end of glossary (i.e., PDE and PDEs).

latex
\newglossaryentry{Linux} { name=Linux, description={is a generic term referring to the family of Unix-like computer operating systems that use the Linux kernel}, plural=Linuces }

Or, for acronyms:

latex
\newacronym[longplural={Frames per Second}]{fpsLabel}{FPS}{Frame per Second}

This will avoid the wrong long plural:

Frame per Seconds instead of Frames per Second

So far, the glossary entries have been defined as key-value lists. Sometimes, a description is more complex than just a paragraph.

For example, you may want to have multiple paragraphs, lists, figures, tables, …

For such glossary entries use the command longnewglossaryentry in which the description follows the key-value list. The computer entry then looks like this:

latex
\longnewglossaryentry{computer} { name=computer } {is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format}
Defining Symbols

When you write a long text full of mathematics (such as a thesis) you will have a bunch of letters which where used to defined to express a certain quantity. For example you might have used the letter d as the diameter of a circle. It would be a great assistance to the reader if all relevant symbols were to be compiled into a list for the reader to reference. These are called nomenclature and for this the glossary package also allows us to define symbols:

latex
\newglossaryentry{pi} { name={\ensuremath{\pi}}, description={ratio of circumference of circle to its diameter}, sort=pi }

We can also define both a name and a symbol:

latex
\newglossaryentry{real number} { name={real number}, description={include both rational numbers, such as $42$ and $\frac{-23}{129}$, and irrational numbers, such as $\pi$ and the square root of two; or, a real number can be given by an infinite decimal representation, such as $2.4871773339\ldots$ where the digits continue in some way; or, the real numbers may be thought of as points on an infinitely long number line}, symbol={\ensuremath{\mathbb{R}}} }

Note that not all glossary styles show defined symbols.

Defining Acronyms

To define a new acronym you use the \newacronym macro:

latex
\newacronym{<label>}{<abbreviation>}{<full text>}

where <label> is the unique label identifying the acronym, <abbrv> is the abbreviated form of the acronym and <full> is the expanded text. For example:

latex
\newacronym{lvm}{LVM}{Logical Volume Manager}

Defined acronyms can be put in separate list if you use acronym package option:

latex
\usepackage[acronym]{glossaries}

7.2.2 Using in the Text

When we have defined a term, we can use it in a document. There are many different commands used to refer to glossary terms.

General References

A general reference is used with \gls command. If, for example, you have glossary entries defined as those above, you might use it in this way:

latex
\documentclass[]{article} \usepackage{glossaries} \newglossaryentry{Linux} {name=Linux, description={is a generic term referring to the family of Unix-like computer operating systems that use the Linux kernel}, plural=Linuces } \makeglossaries \begin{document} \Gls{Linux} is a great operating system as one of the great thing about \gls{Linux} is that it is open source and which allows numerous \glspl{Linux} to flourish. \end{document}
PIC
Figure 7.1:
Command Description
\gls{<label>} prints the term associated with <label> passed as its argument. If the hyperref package was loaded before glossaries it will also be hyperlinked to the entry in glossary.
\glspl{<label>} prints the plural of the defined term, other than that it behaves in the same way as gls.
\Gls{<label>} prints the singular form of the term with the first character converted to upper case .
\Glspl{<label>} prints the plural form with first letter of the term converted to upper case.
\glslink{<label>}{<alternate text>} creates the link as usual, but typesets the alternate text instead. It can also take several options which changes its default behavior (see the documentation).
\glssymbol{<label>} This command prints what ever is defined in \newglossaryentry{<label>}{symbol={...}}
\glsdesc{<label>} prints what ever is defined in \newglossaryentry{<label>}{description={...}}
Referring Acronyms

7.2.3 Displaying the Glossary

To display the sorted list of terms you need to add the following cod

latex
\printglossaries

at the place you want the glossary and the list of acronyms to appear. If all entries are to be printed the command

latex
\glsaddall

can be inserted before \printglossaries. You may also want to use \usepackage[nonumberlist]{glossaries} to suppress the location list within the glossary.