Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It seems that refcheck does not recognize references made by cleveref:

\documentclass{article}
\usepackage{amsmath}
\usepackage{cleveref}
\usepackage{refcheck}

\begin{document}
\begin{align}
  a & = b \label{eq:a} \\
  c & = d \label{eq:b}
\end{align}

See~\eqref{eq:a}, \cref{eq:b}.

\begin{figure}
  \caption{Figure 1}
  \label{fig:a}
\end{figure}
\begin{figure}
  \caption{Figure 2}
  \label{fig:b}
\end{figure}

See Figure~\ref{fig:a}, \cref{fig:b}.

\end{document}

Here, refcheck marks eq:b and fig:b as unreferenced.

  1. Is there a way to make the two packages work together?
  2. Alternatively, are there replacement packages that do work better?
  3. If the answer to 1) is yes, can this even be achieved for \crefrange?
share|improve this question
    
Have you tried "Poor man's cleveref" (chapter 10 in cleveref's docs)? This should be an easy workaround on a Linux or Mac OS X system. –  krlmlr Dec 19 '12 at 23:19
1  
@user946850 I know that option, but I'm not convinced. As a purist, I don't want to run sed scripts in between. And you still have the false positives when using compressed references (\crefrange, and \cref with several labels). –  mafp Dec 19 '12 at 23:40
add comment

1 Answer

refcheck doesn't know about \cref and \Cref. We can add a macro that makes the package aware of other reference commands:

\documentclass{article}
\usepackage{amsmath}
\usepackage{cleveref}
\usepackage{refcheck}

%%% Infrastructure    
\makeatletter
\newcommand{\refcheckize}[1]{%
  \expandafter\let\csname @@\string#1\endcsname#1%
  \expandafter\DeclareRobustCommand\csname relax\string#1\endcsname[1]{%
    \csname @@\string#1\endcsname{##1}\wrtusdrf{##1}}%
  \expandafter\let\expandafter#1\csname relax\string#1\endcsname
}
\makeatother
%%%

%%% Now we add the reference commands we want refcheck to be aware of
\refcheckize{\cref}
\refcheckize{\Cref}

\begin{document}
\begin{align}
  a & = b \label{eq:a} \\
  c & = d \label{eq:b}
\end{align}

See~\eqref{eq:a}, \cref{eq:b}.

\begin{figure}
  \caption{Figure 1}
  \label{fig:a}
\end{figure}
\begin{figure}
  \caption{Figure 2}
  \label{fig:b}
\end{figure}

See Figure~\ref{fig:a}, \Cref{fig:b}.

\end{document}

enter image description here

share|improve this answer
1  
This is great! But does it work when \creffing multiple labels? And what about \crefrange and friends? -- It seems that at least one of the packages should be enhanced to support the other, perhaps both: I imagine a command like \noref (provided by refcheck) that would simply mark a reference as "used" and could be called by cleveref, autoref, nameref, ... –  krlmlr Dec 19 '12 at 23:06
1  
Nice. Unfortunately, I use \cref almost exclusively for multiple references to employ the compression feature, and in this case your solution obviously won't work. I guess one needs to hook deeper into the packages. Should I ask the cleveref author for active support of refcheck, or the refcheck author (I'm not sure if he is still an active Texie.)? –  mafp Dec 19 '12 at 23:09
    
@user946850 refcheck simply modifies \ref and \pageref to write \usedref in the .aux file; the "refcheckized" macros do just the same. –  egreg Dec 19 '12 at 23:09
    
@mafp I'm afraid that this requires much more work. –  egreg Dec 19 '12 at 23:10
    
@mafp: According to egreg's comment, it seems that there's no need to modify refcheck, but cleveref (or its author...) should be made aware of that package. The cleveref docs suggest that (a) the package is well maintained and (b) the author is not aware of refcheck (quick search for "refcheck"). It would definitely be a great improvement for cleveref... –  krlmlr Dec 19 '12 at 23:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.