Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hook to \NR@setref #250

Open
linasstonys opened this issue Jul 5, 2022 · 3 comments
Open

add hook to \NR@setref #250

linasstonys opened this issue Jul 5, 2022 · 3 comments

Comments

@linasstonys
Copy link

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

@u-fischer
Copy link
Member

Please show an example document with a use case.

@linasstonys
Copy link
Author

linasstonys commented Jul 5, 2022

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

@u-fischer
Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants