About
Shop
LaTeX
Free Software
Books
News
Contact
Blog
News (2017-09-10): New application bib2gls for use with glossaries-extra.sty.

Gallery (glossaries-extra): Adjusting Parenthetical Style

Image of
user parenthetical style sample
This example uses the glossaries-extra package, which extends the glossaries package and provides better abbreviation handling. You'll need at least version 1.04 of glossaries-extra.sty (you'll also need a fairly up-to-date version of glossaries.sty as well).

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

This example adjusts the long-short-user style so that the parenthetical part is omitted and both the long and short forms are emphasized. This means that on first use only the long form (emphasized) is displayed and on subsequent use only the short form (emphasized) is displayed. Note that this modification also affects \glsxtrfull so that it will only display the long form.

Note that as from version 1.17, the glossaries-extra package now provides the style long-only-short-only, which only displays the long form on first use and only displays the short form on subsequent use. (An example follows at the bottom of this page.)

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

\usepackage{glossaries-extra}

\makeglossaries

\setabbreviationstyle{long-short-user}

\renewcommand*{\glsabbrvuserfont}[1]{\emph{#1}}
\renewcommand*{\glslonguserfont}[1]{\emph{#1}}

\renewcommand*{\glsxtruserparen}[2]{}


\newabbreviation{cbot}{C.~botulinum}{Clostridium botulinum}
\newabbreviation{putida}{P.~putida}{Pseudomonas putida}

\begin{document}

First use: \gls{cbot}, \gls{putida}.

Next use: \gls{cbot}, \gls{putida}.

\printglossaries
\end{document}

If you don't use arara, you need to run the following commands:
pdflatex sample-bacteria
makeglossaries sample-bacteria
pdflatex sample-bacteria
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.

Download: PDF, document source.

The alternative approach that uses the new long-only-short-only:

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

\usepackage{glossaries-extra}

\makeglossaries

\setabbreviationstyle{long-only-short-only}

\renewcommand*{\glsabbrvonlyfont}[1]{\emph{#1}}
\renewcommand*{\glslongonlyfont}[1]{\emph{#1}}

\newabbreviation{cbot}{C.~botulinum}{Clostridium botulinum}
\newabbreviation{putida}{P.~putida}{Pseudomonas putida}

\begin{document}

First use: \gls{cbot}, \gls{putida}.

Next use: \gls{cbot}, \gls{putida}.

\printglossaries
\end{document}

The result is the same as before. (Not illustrated in this example, but in this case \glsxtrfull will show the short form in parentheses. Remember that \glsxtrfull doesn't always replicate the format displayed by the first use of \gls.)

Last modified: 2017-08-09.

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.

© 2016 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