Smile for the Camera: a new cybercrime short story ebook.

Gallery: Acronyms (With Descriptions)

image of list of abbreviations with full form followed by the description after a line break
This example uses the long-short-desc acronym style which constructs the name field from the long form followed by the short form in parentheses (unlike Acronyms (No Descriptions) where the name is just obtained from the short form). This means it needs a glossary style suitable for wide names, such as the altlist glossary style.

I’ve used the acronym option to create the acronym glossary. Since I’m not using the main glossary, there’s no point defining it, so I’ve used nomain to suppress its creation. Obviously, if you want to adapt this example so that it also uses the main glossary, you should remove the nomain option.

The initial comment lines below are arara directives. You can remove them if you don’t use arara.

 % arara: pdflatex
 % arara: makeglossaries
 % arara: pdflatex
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[nopostdot,toc,
 acronym,% create "acronym" glossary
 nomain% don't create "main" glossary
]{glossaries}

\makeglossaries

\setacronymstyle{long-short-desc}

\loadglsentries[acronym]{example-glossaries-acronym-desc}

\begin{document}

\chapter{Sample}

First use:

\forglsentries{\thislabel}{\gls{\thislabel}. }

Next use:

\forglsentries{\thislabel}{\gls{\thislabel}. }

\printglossary[type=acronym,style=altlist]

% or
%\printacronyms[style=altlist]
% or
%\setglossarystyle{altlist}
%\printglossaries

\end{document}

(Note that with the acronym package option I could also have used \printacronyms[style=altlist] instead of \printglossary[type=acronym,style=altlist].)

This document loads the hyperref package, which creates hyperlinks from the entries in the document (referenced using commands like \gls) to their definition in the glossary. These hyperlinks are displayed in red text. I’ve used \forglsentries for this example to iterate over all the defined entries. In practice, you would typically just use commands like \gls{label} in the text. For example:

Here is a reference to the term \gls{ndl}.

The entries have all been defined in the file example-glossaries-acronym-desc.tex, which you should find installed in the same location as the glossaries package (or in a sub-directory called test-entries). The entry definitions look like this:

\newacronym[type=\glsdefaulttype,description={fringilla a, euismod
sodales,
  sollicitudin vel, wisi}]{ndl}{NDL}{nam dui ligula}

\newacronym[type=\glsdefaulttype,description={non
justo}]{mal}{MAL}{morbi auctor lorem}

\newacronym[type=\glsdefaulttype,description={pretium at, lobortis
vitae, ultricies et,
tellus}]{nll}{NLL}{name lacus libero}

Note that I’ve used type=\glsdefaulttype to allow for situations where I might want to load the entries into a different glossary. (For example, I may want to have multiple lists of acronyms for different subject areas.) The target glossary is specified in the optional argument of \loadglsentries.

If you don’t use arara, you need to run the following commands:

pdflatex acronym-desc
makeglossaries acronym-desc
pdflatex acronym-desc

(See Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.)

I’ve used the toc option to add the glossary to the table of contents. I’ve also used the nopostdot option to remove the terminating full stop that is placed by default after the description. The entries all have a “1” after the description. This is the page number on which the entry was referenced. In this sample document all the entries were referenced on page 1. If you don’t want these numbers you can use the nonumberlist option.

Download: PDF (44.73K), source code (651B), sample glossary definitions (1.19K).