0

Normally, the glossaries-extra package displays the long form of an abbreviation only the first time.

I would like to set the number of times that the long form of abbreviations are shown, before it starts showing the short form.

For example:

\documentclass{article}
\usepackage{glossaries-extra}

\setabbreviationstyle{long-only-short-only}
\glssetcategoryattribute{shortperiod}{discardperiod}{true}
\glssetcategoryattribute{shortperiod}{retainfirstuseperiod}{true}

\newabbreviation[category=shortperiod]{etc}{etc.}{etcetera}

\begin{document}
  \gls{etc}. \gls{etc}. \gls{etc}. \gls{etc}. 
\end{document}

Results in:

etcetera. etc. etc. etc.

However, I would like to set the number of times that the long form is displayed. E.g., if I set the long form to be shown three times, the output would be:

etcetera. etcetera. etcetera. etc.

1 Answer 1

1

I don't think you can easily do that. AFAIK you'd need to turn on counting and then check the counter in order to respond accordingly. There are alternative ways, though.

\glsreset{etc} will unset a flag corresponding to the first use. Hence, afterwards on the next issue of \gls{...}, you will get the "first form" or "full form" depending on your global settings. In glossary-extra, the equivalent is \gls[prereset]{etc}, which combines \glsreset{...} and \gls{...} in one macro.

I think if you want to typeset a term in long or full form in specific place after the first use, the recommended macros are \glsxtrfull{...}, \glsxtrlong{...}, or \glsxtrshort{...} for the full, long, and short forms, respectively; additionally, these macros are independent to global settings.

This code will produce the expected output

\documentclass{article}
\usepackage{glossaries-extra}

\setabbreviationstyle{long-only-short-only}
\glssetcategoryattribute{shortperiod}{discardperiod}{true}
\glssetcategoryattribute{shortperiod}{retainfirstuseperiod}{true}

\newabbreviation[category=shortperiod]{etc}{etc.}{etcetera}

\begin{document}
\gls{etc}. \glsxtrlong{etc}. \glsxtrlong{etc}. \gls{etc}.
\end{document}

enter image description here

1
  • Thanks @Celdor! I will do it manually. I was hoping there was an easier way, since I might mistakenly add an extra \gls{etc} somewhere in between the first few \glsxtrlong{etc} entries. In my real case, they are not so close together as in this MWE. Thanks again for your help!
    – abrac
    Dec 16, 2022 at 19:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .