This question follows a previous question of mine: Prepend different stuffs to starred and unstarred \chapter commands.
In some circumstances, a starred macro in definition of another starred/unstarred macro doesn't work as expected. The following MCE works like a charm but, as soon as the glossaries packages is loaded, the star of \resetsecnumdepth looks like disconnected: it appears in the text.
\documentclass{book}
\usepackage{xparse}
\usepackage{tocvsec2}
% \usepackage{glossaries}
%
\let\ORIchapter\chapter%
\RenewDocumentCommand\chapter{som}{%
\IfBooleanTF{#1}
{
\setsecnumdepth{none}%
}
{%
\resetsecnumdepth*
}
\IfNoValueTF{#2}
{\ORIchapter{#3}}
{\ORIchapter[#2]{#3}}%
}
%
\setsecnumdepth{chapter}
\begin{document}
\chapter{A chapter}
\end{document}
The problem doesn't come from xparse package, as the following MCE, using only
LaTeX macros, has the same trouble.
\documentclass{book}
\usepackage{tocvsec2}
\usepackage{glossaries}
%
\let\ORIchapter\chapter%
\makeatletter%
\renewcommand\chapter{%
\@ifstar{\starred@chapter}{\unstarred@chapter}%
}
\newcommand{\starred@chapter}{%
\setsecnumdepth{none}%
\ORIchapter%
}%
\newcommand{\unstarred@chapter}{%
\resetsecnumdepth*
\ORIchapter%
}%
%
\makeatother%
%
\setsecnumdepth{chapter}
\begin{document}
\chapter{A chapter}
\end{document}
I had a look of the glossaries' code, and made some tests (patching the
glossaries macros involving \chapter in order they use \ORIchapter instead) but I didn't succeed to debug the trouble (neither warning nor error in the .log file).
glossariesdoesn't explicitly redefine\@ifstarso it must load something else that does. – Nicola Talbot Mar 09 '14 at 19:59amsgenthat redefines it. – Nicola Talbot Mar 09 '14 at 20:00tocvsec2. Sorry. – egreg Mar 09 '14 at 20:36:-)– Nicola Talbot Mar 09 '14 at 20:49tocvsec2(2014/03/10 v1.3a) should have solved the issue. – egreg Mar 11 '14 at 00:11