# Why \secref command in memoir with cleveref and nomencl no longer works

The document below, with a chapter/section scheme in a memoir class document, uses a custom \secref command. This command allows reference to a section in the shorter form "section s" that would normally appear in the full form "section c.s". Here c is the chapter number and s is the section number.

The \secref command is as kindly provided by Christian Hupfer, from his "trickier" code answer in Reference with just part of section number after decimal point.

This document used to compile without error.

But now instead it gives this error:

./secref-try.tex:40: Use of \@stripdot doesn't match its definition.
<argument> 1
.2
l.40 In section \secref{sec:more}
%% ERROR WITH \@stripdot here


Here is the document:

\documentclass[12pt]{memoir}

%% NOTATION INDEX
\usepackage[nocfg]{nomencl}

%%%%%%%%  BEGIN CROSS-REFERENCING COMMANDS  %%%%%%%%
\RequirePackage{hyperref}

% Added to allow ref to section n, not section m.n
%    trickier' 'code by Christian Hupfer, from
%   https://tex.stackexchange.com/questions/383606/reference-with-just-part-of-section-number-after-decimal-point
\makeatletter
\let\@xp\expandafter
% Stripping the dot from the 1.2 -like reference
\def\@@stripdot#1.#2\@nil{#2}
% Stripping the memoir stuff from the reference,
%    i.e. \M@TitleReference {1.2}{FOO} and handing #1 (1.2) over to the \@@stripdot macro
\def\@stripdot\M@TitleReference #1#2\@nil{\@@stripdot#1\@nil}
% Macro, second level of expansion
\newcommand{\stripdot}[1]{%
\@xp\@stripdot#1\@nil
}
\newcommand{\secref}[1]{%
% Expand the argument first
\IfRefUndefinedExpandable{#1}{%
% Do nothing if #1 is not defined
}{%
}%
}
\makeatother

%%%%%%%%  END CROSS-REFERENCING COMMANDS  %%%%%%%%

\begin{document}

In section \secref{sec:more} %% ERROR WITH \@stripdot here
of \cref{chap:one} \dots .

And in \cref{sec:one} \dots .

\chapter{One}\label{chap:one}

\chapter{Two}

In section \ref{sec:more}

\end{document}


The error does not occur if \usepackage[nocfg]{nomencl} is commented out! Instead, it produces the expected output, including the following first page:

Question:

What's wrong?

Did something change recently in nomencl (which does have changes in version 5.1 dated 2019/02/08), cleveref, hyperref, or even memoir?

• The code in the "Third installment" block of Christian's answer seems to work fine. Any reason for not using it? – Mico Feb 17 at 21:50
• @Mico: I may be able to use that "Third installment" instead, but with my actual, book-length project with many, many style modifications, I cannot tell whether doing so will create further problems. The issue remains as to why the "trickier" version no longer works! – murray Feb 17 at 21:58
• There's nothing like giving the alternative code a try and find out if any "further problems" are created, right? Aside: Is there any particular reason to suspect that "further problems" might be created by the use of the code in the "third installment" block? – Mico Feb 17 at 22:00
• As I recall, Christian's "Third installment" uses \xassoccnt, which did not get along with \calc (and I do need \calc). Or was that package conflict fixed? – murray Feb 17 at 22:12
• The \@stripdot is not by me and we 'talked' about this already, that xassoccnt should be loaded after any package that makes use of calc – user31729 Feb 18 at 15:03

I cannot tell you why the code in the "trickier" block of Christian Hupfer's answer doesn't work for you. However, as I already noted in a comment, the code in the "third installment" block of Christian's answer seems to work just fine.

(Note that the following code expects that version 1.5 or newer of the xassoccnt package is in use.)

\documentclass[12pt]{memoir}
\usepackage[nocfg]{nomencl}

%% The following code is from the 'third instalment'
%% block of the answer posted by Christian Hupfer at
%% https://tex.stackexchange.com/a/383608
\usepackage{xparse,xassoccnt}
\usepackage[user,hyperref]{zref}
\RegisterPostLabelHook{\zlabel}
\makeatletter
% Replace \arabic{section} with \Roman{section} etc. as needed:
\zref@newprop{section}{\arabic{section}}
\newcommand{\secref}[1]{%
\zref@ifrefundefined{#1}{%
\ref{#1}}{%
{\zref@extract{#1}{section}}}}
\makeatother
%% End of code from Christian Hupfer's answer

\begin{document}
Section \secref{sec:two} of \cref{chap:one}

\Cref{sec:two} of \cref{chap:one}

Section \ref{sec:two} of \cref{chap:one}

\chapter{One}\label{chap:one} \dots