1

I would like to enforce non-breaking spaces between the long and short form of acronyms with glossaries/glossaries-extras. I stumbled across this blog post where the author uses the following command in the preamble:

\renewcommand{\acrfullformat}[2]{#1~(#2)} 

However, this doesn't work with my setup:

\usepackage{glossaries}

\usepackage{glossaries-extra}
\glsdisablehyper
\setabbreviationstyle[acronym]{long-short}
\loadglsentries{resources/acronyms}

Any suggestions?

  • 2
    Tip (unrelated to problem): although you can explicitly have \usepackage{glossaries} before \usepackage{glossaries-extra} it's better to leave glossaries-extra to load glossaries implicitly. – Nicola Talbot Dec 7 '18 at 16:54
3

The command \acrfullformat is provided with the base glossaries acronym styles. The glossaries-extra extension package uses a different abbreviation mechanism, which is much more flexible. The long-short style uses \glsxtrfullsep{label} as the separator between the long form and the parenthetical short form. This is simply defined as:

\newcommand*{\glsxtrfullsep}[1]{\space}

(The label is provided as an argument in case some customisation is required, such as if you want to measure the short or long form to determine whether or not a non-breakable space might be appropriate or have a different separator for a particular category.)

So you just need to redefine this command to use a non-breakable space instead:

\documentclass{article}

\usepackage{glossaries-extra}

\setabbreviationstyle[acronym]{long-short}
\loadglsentries{example-glossaries-acronym}% dummy entries

\begin{document}
Some filler, filler, filler, filler, filler, filler, filler, filler text \gls{lid}.

\glsresetall
\renewcommand{\glsxtrfullsep}[1]{~}

Some filler, filler, filler, filler, filler, filler, filler, filler text \gls{lid}.
\end{document}

image of sample document

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.