hyperref icon indicating copy to clipboard operation
hyperref copied to clipboard

[FR] Provide hook for redefinition of `\ltx@label` in `nameref`

Open gusbrs opened this issue 3 years ago • 0 comments

\ltx@label is an internal macro from amsmath which is meant to store the "original" definition of \label for use in amsmath math environments. Since nameref redefines \label itself, it provides support for amsmath by doing \let\ltx@label\label (in nameref.dtx current line 227) after that redefinition has taken place. Furthermore, given that hyperref is meant to be loaded very late, and that it sets nameref to be required at begindocument, this redefinition comes very very late, so it is difficult not to be trampled by it, if one is trying to redefine it. Either recommend loading nameref first as is the usual hyperref suggestion (and if this was completely safe, I doubt hyperref would be set to load nameref so late), or get in the queue of "those who want to be loaded after hyperref".

I'm trying to redefine \ltx@label myself in a package I'm preparing, so that I could add amsmath support, and I'd have to do it after nameref does its job, of course. Given that now we have the new hook management system in place, would hyperref consider the possibility of making this redefinition in a dedicated hook? If that would be possible, it'd be great, so that I could add this support in a reliable and civil manner, and it would be much appreciated.

A word about this particular macro. As said, it is an internal macro from amsmath and, even though it clearly is not an "undisputed area", it is not nearly as busy as the core job of nameref. I have grepped my TeXLive tree and there are some of redefinitions of if but, as far as I can tell, the most relevant cases are nameref and cleveref.

gusbrs avatar Oct 15 '21 15:10 gusbrs