Recent news (2017-04-18): glossaries-extra v1.14 released.

Gallery (glossaries-extra): Abbreviations (With Translations) Sample

This example emulates a set of abbreviations where some of the abbreviations have an accompanying translation. The translations are specified using the user1 key (internally the useri field).

This example document is like the Acronyms (With Translations) Sample but this uses the glossaries-extra extension package whereas the other example just uses the basic glossaries package.

I've used the long-short-user abbreviation style, which was introduced to version 1.04 of glossaries-extra.sty, so this example won't work with older versions. Also, if you want to use the redefinition of \glsxtruserparen you need at least version 4.23 of glossaries.sty in order to use \glscurrentfieldvalue.

I've used the abbreviations option to create the abbreviations 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{article}

\usepackage[T1]{fontenc}
\usepackage[abbreviations,% create "abbreviations" glossary
nomain,% don't create "main" glossary
stylemods=longbooktabs% do the adjustments for the longbooktabs styles
]{glossaries-extra}

\makeglossaries

% The entries in the sample file are all defined using
% \newacronym, which automatically sets the category
% to "acronym". This means that the abbreviation style needs
% to use "acronym" in the optional argument. The glossary
% can be adapted by using the post-description hook for this
% category.

\setglossarystyle{long-booktabs}

% \glscurrentfieldvalue only works with glossaries v4.23 (and above)
\renewcommand{\glsxtrpostdescacronym}{%
\ifglshasfield{\glsxtruserfield}{\glscurrententrylabel}%
{ (English: \glscurrentfieldvalue)}%
{}%
}

\setabbreviationstyle[acronym]{long-short-user}

% Translations are stored in the user1 key in the sample file
% This is the default for the long-short-user style so
% \glsxtruserfield doesn't need changing, but let's illustrate
% changing the font style for the short form:

\renewcommand{\glsabbrvuserfont}[1]{\textsc{\MakeLowercase{#1}}}
\renewcommand*{\glsxtrusersuffix}{\glsxtrscsuffix}

% This is only a minor modification to the default format to
% add "English: " in front of the translation. Requires glossaries
% v4.23 (or later)

\renewcommand*{\glsxtruserparen}[2]{%
\glsxtrfullsep{#2}%
(#1\ifglshasfield{\glsxtruserfield}{#2}{, English: \glscurrentfieldvalue}{})%
}

% Load the entries from the sample file and put them in the
% "abbreviations" glossary.

\begin{document}

\section{Sample}

First use:

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

Next use:

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

\printglossaries

\end{document}


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 just to iterate over all the defined entries for this example. In practice, you would typically just use \gls{label}. For example:
Here is a reference to the term \gls{li}.

The entries have all been defined in the file example-glossaries-acronyms-lang.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,user1={love itself}]{li}{LI}{lorem
ipsum}

\newacronym[type=\glsdefaulttype,user1={produces
none}]{np}{NP}{nulla pariatur}

\newacronym[type=\glsdefaulttype,user1={blame
belongs}]{sic}{SIC}{sunt in culpa}

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 abbreviations-lang
makeglossaries abbreviations-lang
pdflatex abbreviations-lang

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.

The glossaries-extra package automatically sets the toc option to add the glossary to the table of contents (if one is later required), and the nopostdot option, which removes 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.

Download: PDF, document source, sample glossary definitions.