# Making refcheck work with cleveref and amsmath

This is a follow-up question to Making refcheck work with cleveref about refcheck taking notice of references made with cleveref.

The solution proposed by egreg there works fine if amsmath is not loaded. If amsmath is loaded, cleveref behaves differently for labels of amsmath environments and everything after \label is stored verbatim as the label of the object, e.g. the label stored for \label{mylabel} is {mylabel} and not label (at least to my understanding).

This problem is mentioned (without the explanation) in the edit of codebeard's answer for the original question, suggesting to inform refcheck that not only e.g. mylabel but also {mylabel} were used any time \cref{mylabel} is called. This works, but refcheck now also displays the braces of the label name.

Things get worse since cleveref also allows label types, e.g. \label[ineq]{myineq}, which after some setup print ineq. (X) instead of eq. (X) for \cref{myineq} (see mwe). The label name checked and displayed by refcheck in this example is then [ineq]{myineq} instead of myineq.

One can extend the curly braces hack above to inform refcheck about usages of mylabel, {mylabel}, [ineq]{mylabel}, etc, any time \cref{mylabel} is called, but I my question is:

Is there is a better way to have refcheck, cleveref and amsmath interoperability which also prevents the cluttering of the displayed label?

A minimal working example:

\documentclass{article}

\usepackage{amsmath} % if commented out: expected behavior of refcheck
\usepackage{refcheck}
\usepackage{cleveref}

% custom cleveref type 'ineq'
\crefname{ineq}{ineq.}{ineqs.}
\creflabelformat{ineq}{#2{\upshape(#1)}#3}

% refcheck <-> cleveref solution with {mylabel} fix from
% https://tex.stackexchange.com/a/247836 :
\makeatletter
\newcommand{\refcheckize}[1]{%
\expandafter\let\csname @@\string#1\endcsname#1%
\expandafter\DeclareRobustCommand\csname relax\string#1\endcsname[1]{%
\csname @@\string#1\endcsname{##1}%
\expandafter\let\expandafter#1\csname relax\string#1\endcsname
}
\makeatother

\refcheckize{\cref}

\begin{document}

$$\label{myeq} x = y$$

$$\label[ineq]{myineq} x \leq y$$

Reference to \cref{myeq} and \cref{myineq}.

\end{document}


Yields (with hacks)

If the \usepackage{amsmath} line is removed (expected behavior)

If amsmath is used but the hacks are removed, one gets