5

I wanted to compile an old document on a new PC, so basically I switched from texlive 2021 to an up-to-date version of texlive 2023 for the compilation of a longer document (includes glossaries-extra among many other packages). This lead to the following error, which I have reproduced in a quite small example. But I have no idea what to do about it....

I use glossaries-extra for abbreviations (and other stuff). At some point in the document, I want to access only small cap versions, capitalized versions, or all cap versions. The following code uses the three macros \glsfmtname, \Glsfmtname, and \GLSfmtname to do that. The use of the last one gives an error when \GLSfmtname tries to use the macro \GLSxtrtitlename. But not always, only under two conditions, as far as I can tell: 1) The document class has to be e.g. book or scrbook (I also tried article and didn't observe it). 2) There has to be at least one \chapteror \section or similar in the document, otherwise it compiles just fine.

\documentclass{book} % also for scrbook
%\documentclass{article} % NOT for article! (has no chapter, but same behavior for book+\section)
\usepackage{glossaries-extra}
\newabbreviation{xxx}{asa}{a simple abbreviation}

\begin{document}
%\chapter{A chapter}
\section{A section} % uncomment for error


\gls{xxx}

\glsfmtname{xxx} 

\Glsfmtname{xxx} 

\GLSfmtname{xxx}  % <- error: \GLSxtrtitlename undefined

\end{document}

I get the error message:

! Undefined control sequence. \GLSxtrtitlename {xxx} l.14 \GLSfmtname{xxx}

?

Did I miss some setting? Or can this be a bug? Thank you for your help!

2
  • 1
    Can reproduce. This screams bug to me.
    – Dai Bowen
    Apr 22, 2023 at 22:50
  • Thanks for checking. I'll write a bug report then. :) A temporary fix would still be welcome if it's not too much effort.
    – crateane
    Apr 22, 2023 at 22:58

1 Answer 1

5

glossaries-extra stores certain definitions before \markboth and \markright to prevent case-changing from being applied in headings when \glsfmt<field> is used in \section (see "5.3. Entries in Sectioning Titles, Headers, Captions and Contents" for more information). Unfortunately that saving and restoring macros forgets to save a couple of definitions, this is why sectioning commands and book rather than article are required to demonstrate the bug in a minimal fashion.

The issue is in \glsxtrmarkhook, which only stores the \glsxtrtitlename and \Glsxtrtitlename macros (not \GLSxtrtitlename) to be restored later by \glsxtrrestoremarkhook, instead \glsxtrrestoremarkhook ends up trying to restore \GLSxtrtitlename by setting it equal to an undefined \@glsxtr@org@GLSxtrtitlename.

This can be patched (along with \GLSfmtfirst which is affected in the same way due to \GLSxtrtitlefirst not being saved) with

\documentclass{book}
\usepackage{glossaries-extra}
\newabbreviation{xxx}{asa}{a simple abbreviation}

\makeatletter
\apptocmd\glsxtrmarkhook{%
  \let\@glsxtr@org@GLSxtrtitlename\GLSxtrtitlename
  \let\@glsxtr@org@GLSxtrtitlefirst\GLSxtrtitlefirst
}{}{}
\makeatother

\begin{document}
\section{A section}

\gls{xxx}

\glsfmtname{xxx} 

\Glsfmtname{xxx} 

\GLSfmtname{xxx}

\GLSfmtfirst{xxx}

\end{document}

There is also be a related issue with \GLSfmtlong and \GLSfmtlongpl when used in sectioning commands (where the User Guide suggests they would be supported), as \GLSxtrtitlelong and \GLSxtrtitlelongpl are neither saved by \glsxtrmarkhook nor restored by \glsxtrrestoremarkhook.

This can be patched as

\documentclass{book}
\usepackage{glossaries-extra}
\newabbreviation{xxx}{asa}{a simple abbreviation}

\makeatletter
\apptocmd\glsxtrmarkhook{%
  \let\@glsxtr@org@GLSxtrtitlelong\GLSxtrtitlelong
  \let\@glsxtr@org@GLSxtrtitlelongpl\GLSxtrtitlelongpl
  \let\GLSxtrtitlelong\GLSxtrheadlong
  \let\GLSxtrtitlelongpl\GLSxtrheadlongpl
}{}{}
\apptocmd\glsxtrrestoremarkhook{%
  \let\GLSxtrtitlelong\@glsxtr@org@GLSxtrtitlelong
  \let\GLSxtrtitlelongpl\@glsxtr@org@GLSxtrtitlelongpl
}{}{}
\makeatother

\begin{document}
\section{A section \GLSfmtlong{xxx}}

\gls{xxx}

\GLSfmtlong{xxx}

\end{document}

You must log in to answer this question.

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