# Hyperref and nested \glsxtrshort and \glsfmtlong

The glossaries-extra manual recomends the use of \glsxtrshort and friends, when cross-referencing other acronyms in the definition of an acronym. This mechanism, however, appears to break when used together with \glsfmtlong and hyperref, as illustrated by the following MWE:

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

\newabbreviation{ara}{ARA}{a random abbreviation}
\newabbreviation{aaca}{AACA}{another abbreviation containing \glsxtrshort{ara}}

\begin{document}

\section{Section with \glsfmtlong{aaca}}

Text

\end{document}


When compiling, hyperref complains about the command \glsxtrshort:

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing \glsxtrshort' on input line 10.


Accordingly, in the PDF navigation the section title is displayed as "Section with another abbreviation containing ara", i.e. "ara" is not looked up to result in "ARA".

It appears that \glsxtrshort should be expandable, thus causing no trouble for hyperref, but for some reason this fails. How can I refer to other acronyms properly without losing the hyperref functionality?

You can access the short description like this:

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

\newabbreviation{ara}{ARA}{a random abbreviation}
\newabbreviation{aaca}{AACA}{another abbreviation containing \glsxtrshort{ara}}
\pdfstringdefDisableCommands{%
\def\glsxtrshort#1{\csname glo@#1@short\endcsname}%
}
\begin{document}

\section{Section with \glsfmtlong{aaca}}

Text

\end{document}


• @UlrikeFischer So you are basically stripping off \protect to make \glsxtrshort expandable, just for hyperref, correct? Nov 13 '19 at 16:19
• I redefine the command for hyperref yes. Nov 13 '19 at 16:27
• Is there a similar solution you can come up with for \glsxtrshortpl? I tried looking at its expansion and it seems that it is defined by some option checking plus \ns@glsxtrshortpl, which again is protected, but I don't understand the definition of the latter. Nov 13 '19 at 16:41
• My first try (before checking the code) would be \csname glo@#1@shortpl\endcsname` Nov 13 '19 at 16:43
• Yes, indeed that is the solution. So simple, that I didn't think about trying it. :-) Nov 13 '19 at 16:50