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
…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{...}
:
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:
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:
In
addition,
If
you
would
like
to
use makeglossaries
you
will
need
to
have
Perl
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,
To
define
a
term
in
glossary
we
use
the \newglossaryentry
macro:
where <label>
is
a
<settings>
are
comma
separated key=value
pairs
used
to
define
an
entry.
For
example,
to
define
a
entry
for
the
word computer
:
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:
When
you
define
terms,
we
need
to
remember
these
entries
will
be
sorted
by makeindex
or xindy
.
-
While
xindy
is a bit more LaTeX aware, it does it by omitting macros (ï) thereforeincorrectly sorting the above example asnave . -
On the other hand,
makeindex
won’t fare much better either, as it doesn’t understand TeX macros, it will interpret the word exactly as it was defined, putting it inside symbol class, before words beginning withnaa
.
Therefore it’s needed to extend our example and specify how to sort the word:
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”:
Or, for acronyms:
This will avoid the wrong long plural:
Frame per Seconds instead of Frames per Second
So far, the glossary entries have been defined as
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
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
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:
We can also define both a name and a symbol:
\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:
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:
Defined acronyms can be put in separate list if you use acronym package option:
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:
\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}
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
gls .
|
\Gls{<label>}
|
prints the singular form of the term with the
|
\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
at the place you want the glossary and the list of acronyms to appear. If all entries are to be printed the command
can be inserted before \printglossaries
. You may also want to use \usepackage[nonumberlist]{glossaries}
to suppress the
location list within the glossary.