8

I am wondering how would glossaries handle the article 'a' that comes before abbreviations. For e.g.,

Fox Mulder is a Federal Bureau of Investigation special agent educated at Oxford who believes in the existence of extraterrestrials and a government conspiracy to hide the truth regarding them.

However, if I use glossaries to abbreviate FBI later, it would read:

Dana Scully is an FBI special agent, a medical doctor, and scientist who is Mulder's partner. In contrast to his credulity, Scully is a skeptic, basing her beliefs on scientific explanations.

If I move the second statement up it would read:

Scully is an Federal Bureau of Investigation special agent, a medical doctor, and scientist who is Mulder's partner. In contrast to his credulity, Scully is a skeptic, basing her beliefs on scientific explanations.

How can this be prevented with glossaries?

MWE

\documentclass{article}
\usepackage{glossaries}
\newacronym{fbi}{FBI}{Federal Bureau of Investigation}
\begin{document}
Fox Mulder is a \gls{fbi} special agent educated at Oxford
who believes in the existence of extraterrestrials and a
government conspiracy to hide the truth regarding them.

Dana Scully is an \gls{fbi} special agent, a medical doctor,
and scientist who is Mulder's partner. In contrast to his
credulity, Scully is a skeptic, basing her beliefs on
scientific explanations.
\end{document}

2 Answers 2

7

You can use glossaries-prefix which is supplied with the glossaries package:

\documentclass{article}
\usepackage{glossaries-prefix}
\newacronym[
    prefixfirst={a\ },% prefix used on first use
    prefix={an\ }% prefix used on subsequent use
]
{fbi}{FBI}{Federal Bureau of Investigation}
\begin{document}
Fox Mulder is \pgls{fbi} special agent educated at Oxford
who believes in the existence of extraterrestrials and a
government conspiracy to hide the truth regarding them.

Dana Scully is \pgls{fbi} special agent, a medical doctor,
and scientist who is Mulder's partner. In contrast to his
credulity, Scully is a skeptic, basing her beliefs on
scientific explanations.
\end{document}

Fox Mulder is a Federal Bureau of Investigation (FBI) special agent educated at Oxford who believes in the existence of extraterrestrials and a government conspiracy to hide the truth regarding them. Dana Scully is an FBI special agent, a medical doctor, and scientist who is Mulder’s partner. In contrast to his credulity, Scully is a skeptic, basing her beliefs on scientific explanations.

The glossaries-prefix package loads glossaries and adds four new keys: prefix, prefixplural, prefixfirst and prefixfirstplural. You can determine if the prefix field has been provided for a particular entry with \ifglshasprefix{label}{true}{false}. This tests if the prefix field is empty. There are similar commands for the other prefix fields.

The command \pgls¹ has the same syntax as \gls and performs the same test as in Ulrike's answer, so \pgls{fbi} is essentially the same as

\ifglsused{fbi}{\glsentryprefix{fbi}}{\glsentryprefixfirst{fbi}}\gls{fbi}

but is more convenient to use.

Note that there's no space automatically inserted between the prefix and \gls to allow for things like prefix={l'} in French. If you want a second set of prefixes, then you'll have to add the fields manually using \glsaddkey and define a command similar to \pgls.


¹ Similarly for the upper case and plural variants. See the glossaries user manual for the complete list of provided commands.

4
  • One might want to refer to “the FBI”.
    – egreg
    Sep 14, 2017 at 12:48
  • 2
    @egreg In that case one would just write the \gls{fbi} since then it doesn't matter whether or not the abbreviation has been expanded. Sep 14, 2017 at 13:35
  • @NicolaTalbot prefix versions of the \ac commands would be very appreciated ;)
    – stefanct
    Jul 2, 2019 at 8:48
  • Minimal version would be something like \let\pac\pgls \let\Pac\Pgls \let\pacp\pglspl \let\Pacp\Pglspl
    – stefanct
    Jul 2, 2019 at 9:32
7

You can test if an entry has been used:

\documentclass{article}
\usepackage{glossaries}
\newacronym{fbi}{FBI}{Federal Bureau of Investigation}
\begin{document}
Fox Mulder is \ifglsused{fbi}{an}{a} \gls{fbi} special agent educated at Oxford
who believes in the existence of extraterrestrials and a
government conspiracy to hide the truth regarding them.

Dana Scully is \ifglsused{fbi}{an}{a} \gls{fbi} special agent, a medical doctor,
and scientist who is Mulder's partner. In contrast to his
credulity, Scully is a skeptic, basing her beliefs on
scientific explanations.
\end{document}

enter image description here

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.