Bug Tracker RSS feed

I’m currently working on a major new version of the datatool package. This may take a while. Please be patient. (Experimental version available for testing.)

ID 186🔗
Submitted by: Nicola Talbot 🦜
Date: 2021-10-19 09:25:32
Status Closed (Fixed)
Category glossaries
Version 4.47
Summary list style with entrycounter has problematic unexpanded content

Sign in to subscribe to notifications about this report.

Description

The glossaries user manual advises against using the list styles with certain classes and packages. This is mostly due to the content of the \item argument being processed in some way.

Each problematic class and package has its own idiosyncratic method, but hyperref is used in many documents. The relevant commands used in hyperref's \item are actually from the gettitlestring package, so some basic support needs to be provided for gettitlestring.

The provided MWE demonstrates a problem that isn't immediately identifiable in the original document but triggers an error in the second document (test-xr.tex) that cross-references an item in the first document's glossary.

! Undefined control sequence.
\r@glsentry-sample ->{1}{1}{\glsentryitem 
                                          {sample}\glstarget {sample}{\gloss...
l.9 ...ternal glossary entry \ref{glsentry-sample}
This is because the entrycounter option has been used which implements \refstepcounter when the entry name is displayed in the glossary. In the case of the list styles this occurs within the optional argument of \item.

This is due to the entry counter labelling information that's written unexpanded to the aux file:

\newlabel{glsentry-sample}{{1}{1}{\glsentryitem {sample}\glstarget {sample}{\glossentryname {sample}}}{glossaryentry.main.1}{}}
The simple solution is to do
\GetTitleStringSetup{expand}%
\GetTitleStringDisableCommands{%
   \let\glsentryitem\@gobble
   \let\glstarget\@secondoftwo
   \let\glossentryname\glsentryname
}
before the start of the glossary.

My original plan was to add this patch to glossaries-extra-stylemods.sty but I think in this case it's better to put the patch in glossary-list.sty. The only problem will be the cases where the name contains fragile commands, so some limit on the expansion may be necessary.

MWE

Download (518B)

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: pdflatex
\documentclass{article}

\begin{filecontents}{test-xr.tex}
\documentclass{article}
\usepackage{xr}
\externaldocument{mwe}
\begin{document}
Cross-ref external glossary entry \ref{glsentry-sample}.
\end{document}
\end{filecontents}

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

\makeglossaries
\newglossaryentry{sample}{name={sample},
 description={an example}}

\begin{document}
\gls{sample}.
\printglossaries
\end{document}

Evaluation

Fixed in v4.48 (2021-10-19).

The gettitlestring commands are now in \glslistinit. There are some modifications to my original:

\newcommand{\glslistinit}{%
  \ifdef\GetTitleStringDisableCommands
  {%
    \GetTitleStringSetup{expand}%
    \GetTitleStringDisableCommands{%
      \let\glsentryitem\@gobble
      \let\glstarget\@secondoftwo
      \let\glossentryname\glslistexpandedname
      \let\glslistgroupheaderfmt\@firstofone
      \let\glsgetgrouptitle\@firstofone
      \let\glsnavhypertarget\@secondoftwo
    }%
  }%
  {}%
}
To help guard against any fragile commands contained in the name field, this uses \glslistexpandedname which expands to the value of the name field but no further. If any adjustments are required, redefine \glslistinit as appropriate.

Comments

0 comments.


Add Comment

Name (optional):

Are you human? Please confirm the bug report ID (which can be found at the top of this page) or login if you have an account.

Comment:


You can use the following markup:

Block:

[pre]Displayed verbatim[/pre]
[quote]block quote[/quote]

In line:

[tt]code[/tt]
[file]file/package/class name[/file]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url] [sup]superscript[/sup]
[sub]subscript[/sub]

Ordered list:
[ol]
[li]first item[/li]
[li]second item[/li]
[/ol]

Unordered list:
[ul]
[li]first item[/li]
[li]second item[/li]
[/ul]

You can use the Preview button to review your message formatting before submitting.

Page permalink: https://www.dickimaw-books.com/bugtracker.php?key=186