Gallery: Initialisms

image showing sample document with initialisms
This example uses the glossaries-extra package, which extends the glossaries package and provides better abbreviation handling.

This example uses the long-short style for abbreviations that have been assigned to the initialisms category (the eg and si entries). The style must be set before the abbreviations that use that style are defined. For example:

\setabbreviationstyle[initialism]{short-long}

\newabbreviation[category=initialism]{eg}{eg}{for example}
\newabbreviation[category=initialism]{si}{SI}{sample initials}

General abbreviations identified with the default abbreviation category (just the html entry in this example) use the long-short-sc style. Since the default abbreviation is used here, it may be omitted from the optional arguments of \setabbreviationstyle and \newabbreviation:

\setabbreviationstyle{long-short-sc}

\newabbreviation{html}{html}{hypertext markup language}

The initialisms have full stops (periods) automatically inserted by setting the insertdots attribute for entries assigned to the initialism category:

\glssetcategoryattribute{initialism}{insertdots}{true}
If this attribute is set, it’s generally a good idea to set the discardperiod attribute, which will discard a period that follows commands like \gls:
\glssetcategoryattribute{initialism}{discardperiod}{true}

The complete document code is shown below. 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{article}

\usepackage[T1]{fontenc}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}

\makeglossaries

% set up the styles:
\setabbreviationstyle{long-short-sc}

\setabbreviationstyle[initialism]{short-long}
\glssetcategoryattribute{initialism}{insertdots}{true}
\glssetcategoryattribute{initialism}{discardperiod}{true}

% define the entries:

\newabbreviation{html}{html}{hypertext markup language}

\newabbreviation[category=initialism]{eg}{eg}{for example}
\newabbreviation[category=initialism]{si}{SI}{sample initials}

\begin{document}
\tableofcontents

\section{Sample}
First use: \gls{eg} and \gls{si} (dots inserted) and
\gls{html} (no dots).

Next use: \gls{eg} and \gls{si} (dots) and \gls{html} (no dots).

End of sentence: \gls{eg}. (Trailing period has been discarded.)

End of sentence: \gls{si}. (Spacefactor has also been adjusted.)

\printglossaries

\end{document}

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

pdflatex sample-initialisms
makeglossaries sample-initialisms
pdflatex sample-initialisms

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

The glossaries-extra package automatically implements the toc option (to add the glossary to the table of contents) and 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 (58.41K), source code (973B).