0

Is there a way to specify different indefinite articles for short and long forms of abbreviations using glossaries-extra and bib2gls?


I recently transitioned my project from using the acronym and glossaries-extra packages to just glossaries-extra. I am using bib2gls to compile my glossaries, so I redefined my acronyms as such in my .bib file:

@abbreviation {MO,
    long = {\itshape modus operandi},
    short = {M.O.}
}
@abbreviation {HTML,
    long = {Hypertext Markup Language},
    short = {HTML}
}

With acronym, I was able to specify different indefinite articles depending on whether the long or short form was used:

\begin{acronym}
    \acro{MO}{\itshape modus operandi} \acroindefinite{MO}{an}{a}
    \acro{PM}{prime minister} % package defaults cause `\acroindefinite{PM}{a}{a}` to have no effect
    \acro{HTML}{Hypertext Markup Language} \acroindefinite{HTML}{an}{a}
\end{acronym}

Then, I could write in my document without worrying about whether the correct indefinite article would be used. For instance, the following code:

Oxford Languages defines \iac{MO} as "a particular way or method of doing something."
\Iac{MO}, in other words, is a habitual method of going about some task.
Jeff's \ac{MO} is...

\Ac{HTML} is a computer programming language that provides structure for webpages across the internet.
\Iac{HTML} document has the file name extension ``.html.''
\Ac{HTML} documents are quite ubiquitous, as they are used to...

would give the following output:

Oxford Languages defines a modus operandi (M.O.) as "a particular way or method of doing something." An M.O., in other words, is a habitual method of going about some task. Jeff's M.O. is...

Hypertext Markup Language (HTML) is a computer programming language that provides structure for webpages across the internet. An HTML document has the file name extension “.html.” HTML documents are quite ubiquitous, as they are used to...

With glossaries-extra, I reference acronyms like this:

Oxford Languages defines a \gls{MO} as "a particular way or method of doing something."
A \gls{MO}, in other words, is a habitual method of going about some task.
Jeff's \gls{MO} is...

The result looks like this:

Oxford languages defines a modus operandi (M.O.) as "a particular way or method of doing something." An M.O., in other words, is a habitual method of going about some task. Jeff's M.O. is...

which works well. However, if I reference the acronym earlier in the document, then some of the articles get messed up. This code:

In this document, we will discuss the meaning of a \gls{MO}.

Oxford Languages defines a \gls{MO} as "a particular way or method of doing something."
A \gls{MO}, in other words, is a habitual method of going about some task.
Jeff's \gls{MO} is...

Results in the following (emphasis added):

In this document, we will discuss the meaning of a modus operandi (M.O.).

Oxford languages defines a M.O. as "a particular way or method of doing something." An M.O., in other words, is a habitual method of going about some task. Jeff's M.O. is...

Is there a way to specify and reference indefinite articles for abbreviations that I create using glossaries-extra? For example, can I write something like this in my .bib file:

@abbreviation {MO,
    long = {\itshape modus operandi},
    short = {M.O.},
    indefiniteLong = {a},
    indefiniteShort = {an}
}

and then something like this in my document:

Use one gives ``\glsIndefinite{MO}''

Use two gives ``\glsIndefinite{MO}''

to get:

Use one gives “a modus operandi (M.O.)”

Use two gives “an M.O.”

1 Answer 1

2

There is a package for this. It is part of glossaries-extra and can be loaded by adding prefix as option:

\usepackage[prefix,abbreviations]{glossaries-extra}

Using the TeX definition, you can specify your custom prefixes with:

\newabbreviation[prefix={an\space},prefixfirst={a~}]{MO}{M.O.}{\itshape modus operandi}

Note, that since I am using the \newabbreviation, I also need the abbreviations option. I haven't tested this using a .bib file but it should work the same way, I guess:

@abbreviation {MO,
  long = {\itshape modus operandi},
  short = {M.O.},
  prefixfirst = {a~},
  prefix = {an\space}
}

You can insert your abbreviation inside the text using \pgls{MO} and it will add the right prefix automatically.

For more information see the glossaries docs: https://ctan.mirror.norbert-ruehl.de/macros/latex/contrib/glossaries/glossaries-user.html#sec:prefix

A similar question was also posted a while ago when only using the glossaries package. There you can find another solution without the need of using the glossaries-prefix package: How can glossaries handle the article 'a' or 'an' before abbreviations?

You must log in to answer this question.

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