LaTeX/Glossary

LaTeX logo.svg

LaTeX

Getting Started
  1. Introduction
  2. Installation
  3. Installing Extra Packages
  4. Basics

Common Elements

  1. Document Structure
  2. Text Formatting
  3. Paragraph Formatting
  4. Colors
  5. Fonts
  6. List Structures
  7. Special Characters
  8. Internationalization
  9. Rotations
  10. Tables
  11. Title creation
  12. Page Layout
  13. Importing Graphics
  14. Floats, Figures and Captions
  15. Footnotes and Margin Notes
  16. Hyperlinks
  17. Labels and Cross-referencing

Mechanics

  1. Errors and Warnings
  2. Lengths
  3. Counters
  4. Boxes
  5. Rules and Struts

Technical Texts

  1. Mathematics
  2. Advanced Mathematics
  3. Theorems
  4. Chemical Graphics
  5. Algorithms
  6. Source Code Listings
  7. Linguistics

Special Pages

  1. Indexing
  2. Glossary
  3. Bibliography Management
  4. More Bibliographies

Special Documents

  1. Letters
  2. Presentations
  3. Teacher's Corner
  4. Curriculum Vitae

Creating Graphics

  1. Introducing Procedural Graphics
  2. MetaPost
  3. Picture
  4. PGF/TikZ
  5. PSTricks
  6. Xy-pic
  7. Creating 3D graphics

Programming

  1. Macros
  2. Plain TeX
  3. Creating Packages
  4. Themes

Miscellaneous

  1. Modular Documents
  2. Collaborative Writing of LaTeX Documents
  3. Export To Other Formats

Help and Recommendations

  1. FAQ
  2. Tips and Tricks

Appendices

  1. Authors
  2. Links
  3. Package Reference
  4. Sample LaTeX documents
  5. Index
  6. Command Glossary

edit this boxedit the TOC

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 glossaries package can be used to create glossaries. It supports multiple glossaries, acronyms, and symbols. This package replaces the glossary package and can be used instead of the nomencl package.[1] Users requiring a simpler solution should consider using the longtabu environment and hand-coding their entries.


Jump start

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

↑Jump back a section

Using glossaries

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

\usepackage{glossaries}

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

\usepackage[xindy]{glossaries}

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

\usepackage[toc]{glossaries}

See also Custom TOC Entry at the bottom of this page.

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

\makeglossaries

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

In addition, users who wish to make use of makeglossaries will need to have Perl installed — 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.

↑Jump back a section

Defining glossary entries

To use an entry from 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 \include it in all your documents.

↑Jump back a section

Defining terms

To define a term in glossary you use \newglossaryentry macro:

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

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

For example, to define a computer entry:

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

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:

\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, you need to remember that they will be sorted by makeindex or xindy. While xindy is a bit more LaTeX aware, it does it by omitting latex macros (\"{\i}) thus incorrectly sorting the above example as nave. makeindex 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 naa. Therefore it's needed to extend our example and specify how to sort the word:

\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=naive
}

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

\newglossaryentry{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:

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

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

Defining symbols

Defined entries can also be symbols:

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

You 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:

\newacronym{<label>}{<abbrv>}{<full>}

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:

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

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

\usepackage[acronym]{glossaries}

↑Jump back a section

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

\Gls{naiive} people don't know about
alternative \gls{computer} operating systems:
\glspl{Linux
}, BSDs and GNU/Hurd.

Naïve people don't know about alternative computer opera-
ting systems: Linuces, BSDs and GNU/Hurd.

Description of commands used in above example:

\gls{<label>}

This command 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>}

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

\Gls{<label>}

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

\Glspl{<label>}

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

\glslink{<label>}{<alternate text>}

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

Referring acronyms

Acronyms behave a bit differently than normal glossary terms. On first use the \gls command will display "<full> (<abbrv>)". On subsequent uses only the abbreviation will be displayed.

To reset the first use of an acronym use:

\glsreset{<label>}

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

\glsresetall

Displaying the Glossary

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

\printglossaries

at the place you want the glossary and the list of acronyms to appear.

If all entries are to be printed the command

\glsaddall

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

Separate Glossary and List of Acronyms

\printglossaries will display all the glossaries in the order in which they were defined.[2] 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[3]:

\usepackage[acronym]{glossaries}

\printglossary[type=\acronymtype] % prints just the list of acronyms

Some text between the the list of acronyms and the glossary.

\printglossary % if no option is supplied the default glossary is printed.

Custom Name

The name of the glossary section can be replaced with a custom name or translated to a different language:

\renewcommand*{\glossaryname}{List of Terms}
\deftranslation{Glossary}{List of Terms
}

Custom TOC Entry

When the toc option is added to the usepackage command, the glossary is embedded in the TOC as a section. Use the following code (and omit the toc parameter) to display the TOC as you wish (here as a subsection):

\addcontentsline{toc}{subsection}{Glossary}
\printglossaries

Remove the point

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

\renewcommand*{\glspostdescription}{}

↑Jump back a section

Building your document

Building your document and its glossary requires three steps:

  1. build your LaTeX document — this will also generate the files needed by makeglossaries
  2. invoke makeglossaries — a script which selects the correct character encodings and language settings and which will also run xindy or makeindex if these are specified in your document file
  3. build your LaTeX document again — to produce a document with glossary entries

Thus:

latex doc
makeglossaries doc
latex doc

where latex is your usual build call (perhaps pdflatex) and doc is the name of your LaTeX master file.

If your entries are interlinked (entries themselves link to other entries with \gls calls), you will need to run steps 1 and 2 twice, that is, in the following order: 1, 2, 1, 2, 3.

If you encounter problems, view the doc.log and doc.glg files in a text editor for clues.

Example for use in windows with texmaker

↑Jump back a section

Compile glossary - In windows with texmaker

First we need do download and install xindy for windows, this program install includes the perl interpretator for makeglossaries, and of course xindy for sorting, and add to your windows PATH.
You need to restart Texmaker, after the install of xindy, to update PATH references to xindy, and perl.

  1. Get Download xindy, and install. (Original downloaded here, Original instructions here )

In Texmaker, go to User -> User Commands -> Edit User Commands.
Chose command 1

  1. Menuitem = makeglossaries
  2. Command = makeglossaries %

Now push Alt+Shift+F1and then ->F1

↑Jump back a section

Document preamble

In preample should be. 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
↑Jump back a section

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}
↑Jump back a section

Incluce glossary defitions and print glossary

Include glossary defitions

\begin{document}
\include{INP-00-glossary}

Print glossaries, near end

\appendix
\bibliographystyle{plainnat}
\bibliography{bibtex}
\printindex
\printglossaries
\end{document}
↑Jump back a section

References

  • Using LaTeX to Write a PhD Thesis, Nicola L.C. Talbot, [1]
  • Glossaries, Nomenclature, Lists of Symbols and Acronyms, Nicola L. C. Talbot, link


Clipboard

To do:

  • Add advanced usage
  • Add examples of styles


Previous: Indexing Index Next: Bibliography Management
↑Jump back a section
Last modified on 15 May 2013, at 11:48