LaTeX/Glossary

Many technical documents use terms or acronyms unknown to the general population. It is common practice to add a glossary to make such documents more accessible.

The package can be used to create glossaries. It supports multiple glossaries, acronyms, and symbols. This package replaces the package and can be used instead of the  package. Users requiring a simpler solution should consider hand-coding their entries by using the description environment, or the longtabu environment provided by the package.

Jump start
Place and  in your preamble (after  if present). Then define any number of and  glossary and acronym entries in your preamble (recommended) or before first use in your document proper. Finally add a call to locate the glossaries list within your document structure. Then pepper your writing with macros (and similar) to simultaneously insert your predefined text and build the associated glossary. File processing must now include a call to  followed by at least one further invocation of   or.

Using
To use the package, you have to load it explicitly:

if you wish to use xindy (superior indexing tool ) for the indexing phase, as opposed to makeindex (the default), you need to specify the option:

For the glossary to show up in your Table of Contents, you need to specify the option:

See also Custom Name at the bottom of this page.

Finally, place the following command in your document preamble in order to generate the glossary:

Any links in resulting glossary will not be "clickable" unless you load the package after the  package.

In addition, users who wish to make use of makeglossaries will need to have Perl installed &mdash; this is not normally present by default on Microsoft Windows platforms. That said, makeglossaries simply provides a convenient interface to makeindex and xindy and is not essential.

Defining glossary entries
To use an entry from a glossary you 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.

Note that a defined entry won't be included in the printed glossary unless it is used in the document. This enables you to create a glossary of general terms and just it in all your documents.

Defining terms
To define a term in glossary you use the macro:

is a unique label used to identify an entry in glossary, are comma separated <tt>key=value</tt> pairs used to define an entry.

For example, to define a computer entry:

The above example defines an entry that has the same label and entry name. This is not always the case as the next entry will show:

When you define terms, you need to remember that they will be sorted by <tt>makeindex</tt> or <tt>xindy</tt>. While <tt>xindy</tt> is a bit more LaTeX aware, it does it by omitting latex macros thus incorrectly sorting the above example as <tt>nave</tt>. <tt>makeindex</tt> won't fare much better, because it doesn't understand TeX macros, it will interpret the word exactly as it was defined, putting it inside symbol class, before words beginning with <tt>naa</tt>. Therefore it's needed to extend our example and specify how to sort the word:

You can also specify plural forms, if they are not formed by adding “s” (we will learn how to use them in next section):

Or, for acronyms:

This will avoid the wrong long plural: Frame per Seconds.

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, itemized lists, figures, tables, etc. For such glossary entries use the command <tt>longnewglossaryentry</tt> in which the description follows the key-value list. The computer entry then looks like this:

Defining symbols
Defined entries can also be symbols:

You can also define both a name and a symbol:

Note that not all glossary styles show defined symbols.

Defining acronyms
To define a new acronym you use the macro:

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

Defined acronyms can be put in separate list if you use <tt>acronym</tt> package option:

Using defined terms
When you have defined a term, you 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 command. If, for example, you have glossary entries defined as those above, you might use it in this way:

Description of commands used in above example:

This command prints the term associated with passed as its argument. If the package was loaded before  it will also be hyperlinked to the entry in glossary.

This command prints the plural of the defined term, other than that it behaves in the same way as.

This command prints the singular form of the term with the first character converted to upper case.

This command prints the plural form with first letter of the term converted to upper case.

This command 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).

This command prints what ever is defined in \newglossaryentry{ }{symbol={Output of glssymbol}, ...}

This command prints what ever is defined in \newglossaryentry{ }{description={Output of glsdesc}, ...}

Referring acronyms
Acronyms behave a bit differently to normal glossary terms. On first use the command will display " ". On subsequent uses only the abbreviation will be displayed. If this isn't happening, setting is required.

To reset the first use of an acronym, use the command:

or, if you want to reset the use status of all acronyms:

Similarly, to unset the first use of an acronym so that only the abbreviation will be displayed, use:

or, for all acronyms:

If you just want to print the long version of an acronym without the abbreviation " ", use :

If you just want to print the long version of an acronym with the abbreviation " ", use :

If you just want to print the abbreviation " ", use :

= Displaying the Glossary = To display the sorted list of terms you need to add:

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. You may also want to use to suppress the location list within the glossary.

Separate Glossary and List of Acronyms
will display all the glossaries in the order in which they were defined. If no custom glossaries are defined, the default glossary and the list of acronyms will be displayed.

The glossary and the list of acronyms can be displayed separately in different places :

Dual entries with reference to a glossary entry from an acronym
It may be useful to have both an acronym and a glossary entry for the same term. To link these two, define the acronym with a reference to the glossary entry like this:

Refer to acronym with \gls{OWD} and the glossary with \gls{gls-OWD}

To make this easier, we can use this command (modified from example in the official docs):

Syntax: \newdualentry[glossary options][acronym options]{label}{abbrv}{long}{description}

then, define new (dual) entries for glossary and acronym list like this:

Custom Name
The name of the glossary section can be replaced with a custom name or translated to a different language. Add the option to  to specify the glossary's title. Add the option to specify a the title used in the table of content (if not used,  is used as default).

Remove the point
To omit the dot at the end of each description, use this code:

Changing Glossary Entry Presentation Using Glossary Styles
A number of pre-built styles are available, and can be changed easily using

Commonly used styles include


 * list

My Term Has some long description 7, 9


 * altlist (inserts newline after term and indents description)

My Term Has some long description 7, 9


 * altlistgroup or listgroup (group adds grouping based on the first letters of the terms)

M My First Term Has some long description 7, 9 My Second Term Has some long description 7, 9


 * altlisthypergroup or listhypergroup (hyper adds an hyperlinked 'index' at the top of each glossary to jump to a group)

A|B|C|D|F|G|I|M|O|R|S|C|D|G|M|P A A First term Has some long description 7, 9 B Barely missed first Has some long description 7, 9

Building your document
To add glossary into your final document requires:


 * 1) build your LaTeX document &mdash; this will also generate the aux file/s required by the <tt>makeglossaries</tt>
 * 2) invoke <tt>makeglossaries</tt> &mdash; a script which selects the correct character encodings and language settings and which will also run <tt>xindy</tt> or <tt>makeindex</tt> if these are specified in your document file
 * 3) build your LaTeX document again &mdash; to produce a document with glossary entries

Thus:

latex doc makeglossaries doc latex doc

where <tt>latex</tt> is your usual build call, perhaps,   and <tt>doc</tt> is the name of your LaTeX master file without file extention. Option  can be used topoint where aux and other intermediate files are. If your entries are interlinked (entries themselves link to other entries with calls), you will need to run steps 1 and 2 twice, that is, in the following order: 1, 2, 1, 2, 3.

Any issues will be reported in <tt>doc.log</tt> and <tt>doc.glg</tt> files.

= Example for use in windows with Texmaker =

Compile glossary with xindy - In Windows with Texmaker
In TeX Live and since June 2015 in MikTeX <tt>xindy</tt> is already included.

There is only one issue with path of the install directory of MikTeX containing spaces. It can be solved via the following edit: http://tex.stackexchange.com/questions/251221/miktex-and-xindy-problems/251801#251801

You need to restart Texmaker after installation of <tt>xindy</tt>, to update PATH references to <tt>xindy</tt> and Perl binaries.

Then, in Texmaker, go to User -> User Commands -> Edit User Commands. Choose command 1 Now push Alt+Shift+F1and then ->F1
 * 1) Menuitem = makeglossaries
 * 2) Command = makeglossaries %

Note, for use with the "use build directory" option of Texmaker: makeglossaries needs to find the aux file. Thankfully, while Texmaker does not help there, the option -d  of makeglossaries provides for the subdirectory case. Hence the Command in this case should be:

Command = makeglossaries -d build % instead.

Document preamble
In preamble should be included (note, hyperref should be loaded before the glossaries): \usepackage[nomain,acronym,xindy,toc]{glossaries} % nomain, if you define glossaries in a file, and you use \include{INP-00-glossary} \makeglossaries \usepackage[xindy]{imakeidx} \makeindex

Glossary definitions
Write all your glossaries/acronyms in a file: Ex: INP-00-glossary.tex \newacronym{ddye}{D$_{\text{dye}}$}{donor dye, ex. Alexa 488} \newacronym[description={\glslink{r0}{F\"{o}rster distance}}]{R0}{$R_{0}$}{F\"{o}rster distance} \newglossaryentry{r0}{name=\glslink{R0}{\ensuremath{R_{0}}},text=F\"{o}rster distance,description={F\"{o}rster distance, where 50\% ...}, sort=R} \newglossaryentry{kdeac}{name=\glslink{R0}{\ensuremath{k_{DEAC}}},text=$k_{DEAC}$, description={is the rate of deactivation from ... and emission)}, sort=k}

Include glossary definitions and print glossary
Include glossary definitions in the preamble (Before "\begin{document}") \loadglsentries[main]{INP-00-glossary} % or using \input: %\input{INP-00-glossary} \begin{document}

Print glossaries, near end \appendix \bibliographystyle{plainnat} \bibliography{bibtex} \printindex \printglossaries \end{document}