hyperref
hyperref copied to clipboard
add hook to \NR@setref
Could you define a new command \def\ref@name{#1} and add a new hook to ref the same like it is done in \label:
\def\NR@setref#1{%
\def\ref@name{#1}%
\setref@hook
\begingroup
\@safe@activestrue
\expandafter
\endgroup
\expandafter\NR@@setref\csname r@#1\endcsname
}%
\def\label#1{%
\@bsphack
\begingroup
\def\label@name{#1}%
\label@hook
Thanks
Please show an example document with a use case.
This is just a hook and use cases can be any. For example write undefined refs positions
\appto\setref@@hook{\write@refposs@info}
\def\write@refposs@info{%
\@ifundefined{r@\ref@name}{%
\pdfsavepos
\protected@write\@auxout{}%
{\string\refposs{\ref@name}{{\the\inputlineno}{\number\c@page}{\number\pdflastxpos sp}{\number\pdflastypos sp}}}%
}{}%
}
that information can be formatted and printed at the end of the file as a helper for user
while I agree that such a hook could be useful (the showkeys package actually do something like that) I don't think that it should be added by nameref, but in the kernel (as should be the similar hook for \label).