考虑以下 MWE:
\documentclass[12pt]{article}
\usepackage[colorlinks]{hyperref}
\usepackage[norefs]{refcheck}
\begin{document}
Why?
\label{stuff}
Because \autopageref{stuff}
\end{document}
\autopageref 命令不起作用。是否有类似使用 cleveref 使 refcheck 工作我应该用吗?
编辑:此时,即使是“我不知道”这样的评论也会受到赞赏。
答案1
尝试一下这个:
\documentclass[12pt]{article}
\usepackage[verbose,colorlinks]{hyperref}
\usepackage[norefs]{refcheck}
\makeatletter
\renewcommand*{\autopageref}{\@ifstar{\@autopagereffstar}{\@autopagereffnostar}}
\newcommand*{\@autopagereffstar}[1]{\HyRef@autopagerefname \pageref{#1}}
\newcommand*{\@autopagereffnostar}[1]{\hyperref[#1]{\HyRef@autopagerefname \pageref{#1}}}
\makeatother
\begin{document}
Why?
\label{stuff2}
\label{stuff}
Because \autopageref{stuff}
\end{document}
这是日志:
Package: `refcheck' v1.9.1 <2013/02/14>
options: showrefs, showcites, msgs, chckunlbld
Package refcheck Warning: Unused label `stuff2' on input line 14.
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/se-ascii-print.def)
[1] (./test.aux) )
Output written on test.pdf (1 page).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.
使用@Naphaneal 提供的链接中提出的解决方法:
\documentclass[12pt]{article}
\usepackage[verbose,colorlinks]{hyperref}
\usepackage[norefs]{refcheck}
\makeatletter
\AtBeginDocument{%
\@ifpackageloaded{refcheck}
{%
\@ifundefined{hyperref}{}{%
\let\T@ref@orig\T@ref%
\def\T@ref#1{\T@ref@orig{#1}\wrtusdrf{#1}}%
\let\@refstar@orig\@refstar%
\def\@refstar#1{\@refstar@orig{#1}\wrtusdrf{#1}}
\DeclareRobustCommand\ref{\@ifstar\@refstar\T@ref}%
}%
}{}%
}
\makeatother
\begin{document}
Why?
\label{stuff2}
\label{stuff}
Because \autopageref{stuff}
\end{document}
这是我得到的:
Package: `refcheck' v1.9.1 <2013/02/14>
options: showrefs, showcites, msgs, chckunlbld
Package refcheck Warning: Unused label `stuff2' on input line 25.
Package refcheck Warning: Unused label `stuff' on input line 26.
LaTeX Warning: Reference `*' on page 1 undefined on input line 27.
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/se-ascii-print.def)
[1] (./test.aux)
LaTeX Warning: There were undefined references.
)
Output written on test.pdf (1 page).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.
这是制作的文件
希望这会有所帮助!
答案2
正如解释的那样这里refcheck 在某些层面上不尊重 hyperref。此外,还提供了一种解决方法,可能对您的情况有所帮助。