6
\documentclass{revtex4-2}
\usepackage{hyperref}
\begin{document}
Hello World
\end{document}

Produces the following warning:

Package nameref Warning: The definition of \label has changed! Check your packages! Replacing it with the kernel definition on input line 145.

Can someone explain to me what the problem is and how I can get revtex working with hyperref without this warning? Maybe it's already well known, then just pointing me to a solution would be fine too, couldn't finde one.

6
  • I am not receiving any warnings in TexLive 2022.
    – John Smith
    Nov 22, 2023 at 20:38
  • @JohnSmith Then I will immediately try to update my TeXStudio and MikTeX. Thanks for testing. Add: I got this warning on Overleaf too btw. Nov 22, 2023 at 20:40
  • 1
    @JohnSmith I still get the error. I use TeXStudio 4.6.3, have updated all MikTeX packages now too. Furthermore on Overleaf the exact same thing happens. (E.g. for those who can access it: overleaf.com/6795341177bpxyndcbphsd#9bc51f ) Nov 22, 2023 at 20:47
  • 1
    That is not an error. Only a warning and it should be harmless. Nov 22, 2023 at 20:53
  • 2
    Complain to the revtex maintainer. If they stop to redefine needlessly label the warning would go away. Nov 22, 2023 at 21:35

1 Answer 1

7

revtex redefines the \label command. In a current LaTeX kernel, \label is defined like this:

\def\label#1{\@bsphack
  \begingroup
  \UseHookWithArguments{label}{1}{#1}%
  \protected@write\@auxout{}%
         {\string\newlabel{#1}{{\@currentlabel}{\thepage}%
          {\@currentlabelname}{\@currentHref}{\@kernel@reserved@label@data}}}%
  \endgroup
  \@esphack}

After revtex the definition is:

\def\label#1{%
 \@bsphack
  \protected@write\@auxout{}{%
   \string\newlabel{#1}{{\@currentlabel}{\thepage}{}{}{}}%
  }%
 \@esphack
}%

That means the hook is missing and the label doesn't store \@currentlabelname and \@currentHref. nameref (and hyperref too) needs the new enhanced \label and so checks the label definition and warns if it detects that is a wrong one and reinstates the kernel version. To get rid of the warning you should try to convince the revtex maintainer to remove their redefinition (which is quite unneeded in a current LaTeX).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .