Bug Tracker 
| ID | 171🔗 |
|---|---|
| Date: | 2021-01-06 14:25:19 |
| Last update: | 2022-10-19 19:57:17 |
| Status | Closed (Fixed) |
| Category | glossaries-extra |
| Version | 1.45 |
| Summary | glossaries-extra does not recognise glossaries commands |
Sign in to subscribe to notifications about this report.
Description
In my thesis I use this package to create a list of symbols/nomenclature. Without the glossaries package and only using glossaries-extra everything is fine, however when adding the former TeX returnsTeX capacity exceeded, sorry [parameter stack size=10000]. \RequirePackage.In the documentation it is stated that glossaries-extra requires glossaries but for some reason it thows an error for me. Removing \usepackage{glossaries} resolves the error. However in this case, commands provided by the package such as \glossarysection are not recognised and thus throws
Undefined control sequence. \renewcommand*{\glossarysection}[2] when attempting the following (which should work according to the glossaries-extra manual (page 192)):
\documentclass{article}
\usepackage{glossaries}
\usepackage[symbols,stylemods={tree},record]{glossaries-extra}
\glsxtrsetgrouptitle{latin}{Latin letters}
\GlsXtrLoadResources[
src={numbers.bib},
type=symbols,
group={letters},% assign group label
set-widest,% needed for 'alttree' styles
save-locations=false
]
\begin{document}
\printunsrtglossary[type=symbols,style=alttreegroup,\printunsrtglossaryunitsetup{section}%
\renewcommand*{\glossarysection}[2][]{\subsection*{Summary}]
\end{document}
I also stated the question over at StackExchange: [Link]
MWE
Download (484B)
\documentclass{article}
\usepackage[symbols,stylemods={tree},record]{glossaries-extra}
\glsxtrsetgrouptitle{latin}{Latin letters}
\GlsXtrLoadResources[
src={numbers.bib},
type=symbols,
group={letters},% assign group label
set-widest,% needed for 'alttree' styles
save-locations=false
]
\begin{document}
\printunsrtglossary[type=symbols,style=alttreegroup,\printunsrtglossaryunitsetup{section}%
\renewcommand*{\glossarysection}[2][]{\subsection*{Summary}]
\end{document}Evaluation
You have some syntax errors in your MWE. The optional argument of \printunsrtglossary should be a key=value list and should not contain commands. The glossaries package is automatically loaded by glossaries-extra and it's best to leave it that way rather than loading glossaries explicitly. So the correct code should be:
\documentclass{article}
\usepackage[symbols,stylemods={tree},record]{glossaries-extra}
\glsxtrsetgrouptitle{latin}{Latin letters}
\GlsXtrLoadResources[
src={example-glossaries-brief},
type=symbols,
group={letters},% assign group label
set-widest,% needed for 'alttree' styles
save-locations=false
]
\begin{document}
\printunsrtglossaryunitsetup{section}%
\renewcommand*{\glossarysection}[2][]{\subsection*{Summary}}
\printunsrtglossary[type=symbols,style=alttreegroup]
\end{document}
However, although this is the recommended approach, it should still be possible to explicitly load glossaries first so I'll investigate.
It seems related to a combination of the symbols and record package options as the following now breaks:
\documentclass{article}
\usepackage{glossaries}
\usepackage[symbols,record]{glossaries-extra}
\begin{document}
Test.
\end{document}
Since this used to work, my guess is that some dependency has changed that is now causing interference.
Update 2021-01-07 13:47 GMT
There seems to be a very specific set of circumstances that triggers this error: glossaries.sty is loaded before glossaries-extra.sty and glossaries-extra.sty is loaded with a mixture of glossaries.sty and glossaries-extra.sty package options where the glossaries.sty options are listed first. So, for example, the following works fine:
\documentclass{article}
\usepackage[symbols,record]{glossaries-extra}
\begin{document}
Test.
\end{document}
as does:
\documentclass{article}
\usepackage[record,symbols]{glossaries-extra}
\begin{document}
Test.
\end{document}
However the following doesn't work:
\documentclass{article}
\usepackage{glossaries}
\usepackage[symbols,record]{glossaries-extra}
\begin{document}
Test.
\end{document}
but switching the options round does work:
\documentclass{article}
\usepackage{glossaries}
\usepackage[symbols,record]{glossaries-extra}
\begin{document}
Test.
\end{document}
So the simplest workaround is to not load glossaries.sty first. If you don't have that option (for example, you are using another package that automatically loads glossaries.sty) then re-order the package options.
For those who want more technical details: the glossaries-extra.sty package defines an internal command \glsxtr@dooption{option} that either does
\setupglossaries{option}
if glossaries.sty has already been loaded or
\PassOptionsToPackage{option}{glossaries}
otherwise. Any options that aren't defined by glossaries-extra.sty are dealt with by the following code:
\DeclareOptionX*{%
\expandafter\glsxtr@dooption\expandafter{\CurrentOption}}
(where \DeclareOptionX is provided by xkeyval, which in turn loads keyval). The record option is defined in glossaries-extra.sty using \define@choicekey. This means that it shouldn't be picked up by \DeclareOptionX. The symbols option is defined in glossaries.sty so it should be picked up by \DeclareOptionX.
What seems to be happening is that when glossaries.sty is loaded first, both symbols and record are being picked up by \DeclareOptionX (which can be verified by inserting \show\CurrentOption at the start of the \DeclareOptionX) but only when symbols is listed first. The symbols option is processed correctly but the record option (which glossaries.sty doesn't recognise) gets stuck in a loop, which results in the following transcript:
> \CurrentOption=macro:
->symbols.
\XKV@doxs ->\show \CurrentOption
\expandafter \glsxtr@dooption \expandafter ...
l.1637 \RequirePackage
{glossaries}
?
> \CurrentOption=macro:
->record.
\XKV@doxs ->\show \CurrentOption
\expandafter \glsxtr@dooption \expandafter ...
l.1637 \RequirePackage
{glossaries}
?
[...]
l.1637 \RequirePackage
{glossaries}
> \CurrentOption=macro:
->record.
\XKV@doxs ->\show \CurrentOption
\expandafter \glsxtr@dooption \expandafter ...
l.1637 \RequirePackage
{glossaries}
! TeX capacity exceeded, sorry [parameter stack size=10000].
\XKV@ifcmd #1#2#3->
\def \XKV@@ifcmd ##1#2##2##3\@nil ##4{\def ##4{##2}\ifx #...
l.1637 \RequirePackage
{glossaries}
where [...] indicates multiple instances of
> \CurrentOption=macro:
->record.
\XKV@doxs ->\show \CurrentOption
\expandafter \glsxtr@dooption \expandafter ...
l.1637 \RequirePackage
{glossaries}
This therefore seems to be an issue with xkeyval or keyval since \DeclareOptionX shouldn't be picking up the record option and it shouldn't be triggering an infinite loop.
Update 2022-10-19: fixed in v1.49 (make sure you also update glossaries and mfirstuc as well).
Comments
2 comments.
Add Comment
Page permalink: https://www.dickimaw-books.com/bugtracker.php?key=171

Date: 2021-01-08 13:37:00
Hello,
I have investigated this and it seems to be an
xkeyvalbug. I could reduce the issue to the following (maybe not so minimal) example:\begin{filecontents}[overwrite,noheader]{glossaries.sty} \DeclareOptionX{symbols}{\typeout{optionX symbols}} \ProcessOptionsX \newcommand*{\setupglossaries}[1]{% \setkeys{glossaries.sty}{#1}\relax} \end{filecontents} \begin{filecontents}[overwrite,noheader]{glossaries-extra.sty} % \RequirePackage{xkeyval} \define@key{glossaries-extra.sty}{record}{\typeout{key record=#1}} \DeclareOptionX*{% \expandafter\setupglossaries\expandafter{\CurrentOption}} \ProcessOptionsX \end{filecontents} \documentclass{article} \usepackage{glossaries} % \usepackage[record=a,symbols]{glossaries-extra} % works \usepackage[symbols,record=a]{glossaries-extra} % breaks \begin{document} Test. \end{document}What seems to be happening is that when you use the keys[symbols,record]inglossaries-extra.sty,xkeyvalchanges the key family fromglossaries-extra.stytoglossaries.sty(given in the argument to\setupglossaries) in order to execute thesymbolsoption. Then, when executingrecord, it gets stuck withglossaries.styand doesn't know that it has to switch back to familyglossaries-extra.sty(given implicitly by running\ProcessOptionsXinsideglossaries-extra.sty), so it gets stuck in a loop, trying to execute optionrecord(which does exist), but failing to find the right family.When you use the keys
[record,symbols], the family starts asglossaries-extra.sty, the optionrecordis executed, then\setupglossarieschanges the family toglossaries.styand the optionsymbolsgets executed there correctly.(beware: some parts of the analysis above may be wrong)
I got to work around the problem with the following patch to
xkeyval:\documentclass{article} % xkeyval patch \usepackage{xkeyval} \makeatletter \def\XKV@t@stoptc#1[#2]#3{% \XKV@makepf{#2}% \XKV@checksanitizeb{#3}\XKV@resa % <-- new family (glossaries.sty) \edef\XKV@resb{% \noexpand\XKV@sp@deflist \noexpand\XKV@fams{\XKV@resa,\XKV@fams}}% <-- new family + old family (glossaries-extra.sty) \XKV@resb \@testopt#1{}% } \def\XKV@@d@x[#1]{% \@ifnextchar<% {\XKV@@@d@x[#1]}% {\edef\XKV@resa{<\@currname.\@currext>}% \expandafter\@swaptwoargs\expandafter {\XKV@resa}{\XKV@@@d@x[#1]}}% } \def\XKV@t@st@pte#1[#2]{% \XKV@makepf{#2}% \@ifnextchar<{\XKV@@t@st@pte#1}% {\edef\XKV@resa{<\@currname.\@currext>}% \expandafter\@swaptwoargs\expandafter {\XKV@resa}{\XKV@@t@st@pte#1}}% } \makeatother \usepackage{glossaries} \usepackage[symbols,record]{glossaries-extra} \begin{document} Test. \end{document}The important part of the patch is the definition of\XKV@t@stoptc, that adds both the new family (glossaries.sty, from\setkeys{glossaries.sty}) and the old family (glossaries-extra.sty, from\ProcessOptionsX) to the list of families to search (\XKV@fams). The old definition redefined\XKV@famsfrom scratch, so the old family was lost.The other two definitions are preemptive corrections to expand
\@currname.\@currextbefore passing it along (it didn't look right to keep them not expanded here).This seems to fix the problem at hand, but I don't know what changed that this stopped working. It doesn't seem to be related to a change in the LaTeX kernel, but who knows. Unfortunately at the moment I don't have access to an older distribution to check what changed.
Also, if this is indeed a bug in
xkeyval, I don't know if the patch is 100% correct. It might cause problems ifxkeyvalis used by other packages, if it doesn't reset the known families. It might happen that you pass some option to a third package that, if the option happens to have the same name, will take effect onglossaries(-extra).sty.