0

So I have two acronyms in my document. One of them involves the other:

\newacronym[plural=AChems,firstplural=Artificial Chemistries (AChems)]{AChem}{AChem}{Artificial Chemistry}
\newacronym[plural=ssAChems,firstplural=subsymbolic \glspl{AChems} (ssAChems)]{ssAChem}{ssAChem}{subsymbolic \gls{AChem}}

The intention is that the first acronym should read "Artificial Chemistry (AChem)" on first usage and "AChem" on second usage. The second acronym should read "subsymbolic AChem (ssAChem)" on first usage (if the artificial chemistry acronym has already been used), and "ssAChem" on second usage.

This actually works fine until I need the first letter to be uppercase. When this happens I get the following error:

Package glossaries Error: Glossary entry `\MakeTextUppercase {A}Chems' has not been defined...

I'm guessing this is the issue of using \makefirstuc with something that contains a \gls command.

So how do I overcome this problem and use acronyms in this way? Or alternatively, is there a best practice which does not require me to use acronyms within others at all?

1

The glossaries user manual advises against using nested links (that is, using commands like \gls within field values that are used by commands like \gls). There's more information in the Nested Links section of the glossaries-extra manual.

The recommended methods are as follows:

Using the base glossaries package.

Write out the actual text in the long, longplural, short and shortplural parts, as appropriate, and use \acrlong in the description:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\makeglossaries
\setacronymstyle{long-short}

\newacronym[longplural=Artificial Chemistries]
{AChem}{AChem}{Artificial Chemistry}

\newacronym[longplural=subsymbolic Artificial Chemistries,
description={subsymbolic \acrlong{AChem}}]
{ssAChem}{ssAChem}{subsymbolic Artificial Chemistry}

\begin{document}
First use: \gls{AChem}, \gls{ssAChem}.

Next use: \gls{AChem}, \gls{ssAChem}.

\glsresetall

First use: \glspl{AChem}, \glspl{ssAChem}.

Next use: \glspl{AChem}, \glspl{ssAChem}.

\glsresetall

First use: \Gls{AChem}, \Gls{ssAChem}.

Next use: \Gls{AChem}, \Gls{ssAChem}.

\printglossaries
\end{document}

image of document

Using the glossaries-extra extension package.

The glossaries-extra package provides some commands specifically for this use, but they still come with some caveats, in particular don't use them at the start of a field as that will interfere with the first letter uppercasing commands.

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}

\makeglossaries
\setabbreviationstyle[acronym]{long-short}

\newacronym[longplural=Artificial Chemistries]
{AChem}{AChem}{Artificial Chemistry}

\newacronym[longplural=subsymbolic \glsxtrp{longpl}{AChem}]
{ssAChem}{ssAChem}{subsymbolic \glsxtrp{long}{AChem}}

\begin{document}
First use: \gls{AChem}, \gls{ssAChem}.

Next use: \gls{AChem}, \gls{ssAChem}.

\glsresetall

First use: \glspl{AChem}, \glspl{ssAChem}.

Next use: \glspl{AChem}, \glspl{ssAChem}.

\glsresetall

First use: \Gls{AChem}, \Gls{ssAChem}.

Next use: \Gls{AChem}, \Gls{ssAChem}.

\printglossaries
\end{document}

If the nested term appears at the start of the field, or if the field is used for sorting, or if the field value needs to be used in an expandable context, then the first method is preferable (with the appropriate modifications needed to convert it for use with glossaries-extra):

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}

\makeglossaries
\setabbreviationstyle[acronym]{long-short}

\newacronym[longplural=Artificial Chemistries]
{AChem}{AChem}{Artificial Chemistry}

\newacronym[longplural=subsymbolic Artificial Chemistries,
description={subsymbolic \glsxtrlong{AChem}}]
{ssAChem}{ssAChem}{subsymbolic Artificial Chemistry}

\begin{document}
First use: \gls{AChem}, \gls{ssAChem}.

Next use: \gls{AChem}, \gls{ssAChem}.

\glsresetall

First use: \glspl{AChem}, \glspl{ssAChem}.

Next use: \glspl{AChem}, \glspl{ssAChem}.

\glsresetall

First use: \Gls{AChem}, \Gls{ssAChem}.

Next use: \Gls{AChem}, \Gls{ssAChem}.

\printglossaries
\end{document}

Alternatively:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}

\makeglossaries
\setabbreviationstyle{long-short}

\newabbreviation[longplural=Artificial Chemistries]
{AChem}{AChem}{Artificial Chemistry}

\newabbreviation[longplural=subsymbolic Artificial Chemistries,
description={subsymbolic \glsxtrlong{AChem}}]
{ssAChem}{ssAChem}{subsymbolic Artificial Chemistry}

\begin{document}
First use: \gls{AChem}, \gls{ssAChem}.

Next use: \gls{AChem}, \gls{ssAChem}.

\glsresetall

First use: \glspl{AChem}, \glspl{ssAChem}.

Next use: \glspl{AChem}, \glspl{ssAChem}.

\glsresetall

First use: \Gls{AChem}, \Gls{ssAChem}.

Next use: \Gls{AChem}, \Gls{ssAChem}.

\printglossaries
\end{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.