The glossaries package

Manages a glossary and a list of acronyms: terms are defined once with \newglossaryentry or \newacronym, used with \gls and listed with \printglossaries.

Loading the package

\usepackage[acronym]{glossaries}

Each term gets a label, a name and a description in the preamble. In the text \gls{label} prints the name. For an acronym the first use prints the long form with the short form in parentheses, and every later use prints the short form.

The lists contain only the terms that were used, sorted alphabetically and with the page numbers of their uses. An external program does the sorting: after the first LaTeX run, makeglossaries processes the files that \makeglossaries created, and a second LaTeX run reads the result.

Main commands

\makeglossariesPreamble: switches on the files for the external sorting.
\newglossaryentry{kernel}{name={kernel}, description={...}}Defines a glossary term.
\newacronym{pdf}{PDF}{Portable Document Format}Defines an acronym: label, short form, long form.
\gls{pdf}Uses a term. \Gls starts with a capital letter, \glspl prints the plural.
\acrshort{pdf}, \acrlong{pdf}, \acrfull{pdf}Force the short, long or full form of an acronym.
\printglossariesPrints all lists. \printglossary[type=\acronymtype] prints only the acronyms.
\usepackage[acronym,toc]{glossaries}acronym creates a separate list of acronyms, toc adds the lists to the table of contents.
\glsaddallLists all defined terms, also the ones that were not used.

Complete example

\documentclass{article}
\usepackage[acronym]{glossaries}
\makeglossaries
\newglossaryentry{kernel}{name={kernel},
  description={The core commands of LaTeX that every document loads}}
\newacronym{pdf}{PDF}{Portable Document Format}
\begin{document}
\section{Output}
The \gls{kernel} writes a \gls{pdf} file. The second use is short: \gls{pdf}.

\printglossaries
\end{document}
Result
The compiled example

Compiled with pdfLaTeX from TeX Live 2023. Tools run in this order: pdflatex → makeglossaries → pdflatex.

Pitfalls

Related pages