Glossary and list of acronyms in LaTeX (glossaries)

With the glossaries package you define each abbreviation once with \newacronym and use it with \gls. The first use prints the long form with the abbreviation in parentheses, later uses only the abbreviation, and \printglossaries prints the sorted list.

Preamble

The snippets on this page need these lines before \begin{document}:

\usepackage[acronym]{glossaries}
\makeglossaries
\newacronym{cpu}{CPU}{central processing unit}
\newacronym{api}{API}{application programming interface}
\newglossaryentry{kernel}{
  name=kernel,
  description={the part of an operating system that manages memory and processes}
}

A list of acronyms

\newacronym{cpu}{CPU}{central processing unit} takes a key, the abbreviation and the long form. The package option acronym creates a separate list for acronyms. The order of the tools is pdflatex, makeglossaries, pdflatex.

Complete document:

\documentclass{article}
\usepackage[acronym]{glossaries}
\makeglossaries
\newacronym{cpu}{CPU}{central processing unit}
\newacronym{api}{API}{application programming interface}
\begin{document}
The \gls{cpu} executes the program. A faster \gls{cpu} shortens the run.
The \gls{api} is described in the next section.

\printglossary[type=\acronymtype]
\end{document}
Result
The compiled example

Glossary entries with a description

\newglossaryentry{key}{name=..., description={...}} defines a term. \gls{key} prints the name, \Gls with a capital first letter and \glspl the plural. \printglossaries prints all lists, here the glossary and the acronyms.

\Gls{kernel} is the term for the core of an operating system.
Two \glspl{kernel} can share one \gls{cpu}.

\printglossaries
Result
The compiled example

Choose the form yourself

\acrshort prints the abbreviation, \acrlong the long form and \acrfull both, whatever was used before. \glsreset{cpu} makes the next \gls{cpu} behave like the first use again.

\acrshort{api}, \acrlong{api}, \acrfull{api}.

\gls{cpu}, then \gls{cpu}. \glsreset{cpu}After the reset: \gls{cpu}.

\printglossaries
Result
The compiled example

Without the makeglossaries program

With \makenoidxglossaries and \printnoidxglossary, LaTeX sorts the entries itself. Two LaTeX runs are enough then. TeX sorts more slowly than the external program, which shows in long lists.

Complete document:

\documentclass{article}
\usepackage[acronym]{glossaries}
\makenoidxglossaries
\newacronym{cpu}{CPU}{central processing unit}
\begin{document}
The \gls{cpu} executes the program.

\printnoidxglossary[type=\acronymtype]
\end{document}
Result
The compiled example

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages