Free Software
Recent news (2017-02-08): Added aliases example to the glossaries-extra.sty gallery.

Gallery (glossaries): Acronyms (With Translations) Sample

Image of acronyms
(with translations) sample
This example emulates a set of acronyms where some of the acronyms have an accompanying translation. The translations are specified using the user1 key (internally the useri field). This means that none of the predefined acronym styles are suitable if the first use must also include the translation. Therefore this example defines a custom acronym style that will insert the translation on first use (if one has been provided). A custom glossary style is also required to ensure the translation also appears in the list of acronyms.

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.

See Abbreviations (With Translations) for an alternative that uses the glossaries-extra extension package.

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

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex



% define an acronym style for the acronyms with a translation:

    {, English: \glsentryuseri{##1}}{})%
    {, English: \glsentryuseri{##1}}{})%
    {, English: \glsentryuseri{##1}}{})%
    {, English: \glsentryuseri{##1}}{})%



% glossary style for acronyms with a translation

    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \ifglshasfield{useri}{##1}{ (English: \glsentryuseri{##1})}{}%
    \space ##2\tabularnewline



First use:

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

Next use:

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


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

none}]{np}{NP}{nulla pariatur}

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 acronym-lang
makeglossaries acronym-lang
pdflatex acronym-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.

I've used the toc option to add the glossary to the table of contents (if one is later required). 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.

Download: PDF, document source, sample glossary definitions.

Last modified: 2017-02-07.

The free resources on this site are funded by book sales, not by adverts. If you would like to help keep this site free of annoying third-party ads, please consider buying a book.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Site Map FAQs