News (2018-01-05): glossaries-extra v1.26 released.

# Gallery (glossaries-extra): Initialisms Sample

This example uses the glossaries-extra package, which extends the glossaries package and provides better abbreviation handling.

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{glossaries-extra}

\makeglossaries

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

\setabbreviationstyle[initialism]{short-long}
\glssetcategoryattribute{initialism}{insertdots}{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

These commands can be run from a terminal or command prompt or you might be able to run them by clicking on a button in your text editor.

This example uses the long-short style for abbreviations that have been assigned to the initialisms category (the eg and si entries).

\setabbreviationstyle[initialism]{short-long}

General abbreviations (the html entry) use the long-short-sc style.
\setabbreviationstyle{long-short-sc}

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