2

This is the answer to the question LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right Why I am getting undefined references?, however that answer brings another question.

On the file abntex2cite there are these lines which seem inoffensive:

%we are repeating \bibcite command as defined in hyperref.sty
%so that we have it all together at one place.
\ifthenelse{\boolean{ABNThyperref}}{% not comment this, but the next two, to fix the warning
\renewcommand{\bibcite}[2]{%
 \@newl@bel{b}{#1}{\hyper@@link[cite]{}{cite.#1}{#2}}}%
  1. https://github.com/abntex/abntex2/blob/master/tex/latex/abntex2/abntex2cite.sty#L547-L548

After several hours commenting things out on that abntex2cite package and testing it against a simple example:

% How to make \PassOptionsToPackage add the option as the last option?
% https://tex.stackexchange.com/questions/385895/how-to-make-passoptionstopackage-add
\PassOptionsToPackage{brazil,main=english}{babel}

\documentclass[10pt,openright,twoside,a5paper]{abntex2}
\usepackage{filecontents}
\usepackage[alf]{abntex2cite}

% Package hyperref Warning: Token not allowed in a PDF string?
% https://tex.stackexchange.com/questions/384885/package-hyperref-warning-token-not
\pdfstringdefDisableCommands{\let\uppercase\relax}

\begin{document}

% How does 'filecontents' keep LaTeX parsing while temporarily stop writing output
% https://tex.stackexchange.com/questions/104159/how-does-filecontents-keep-latex-parsing
\begin{filecontents*}{refs2.bib}
@manual{abntex2classe,
  Author = {abnTeX2 and Lauro C{\'e}sar Araujo},
  Date-Added = {2013-01-09 10:37:38 +0000},
  Date-Modified = {2013-04-05 11:03:48 +0000},
  Organization = {Equipe abnTeX2},
  Title = {A classe abntex2},
  Url = {http://abntex2.googlecode.com/},
  Year = {2013},
  Bdsk-Url-1 = {http://code.google.com/p/abntex2/}}
\end{filecontents*}

The \cite{abntex2classe}.
\bibliography{refs2}
\end{document}

I find out these lines are causing this warning to show up every time I compile my latex files:

Basic Builder: running pdflatex...done.
running pdflatex...done.

No errors. Warnings:

D:\test.tex: LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

No bad boxes.

Hence if I comment these lines on the abntex2cite.sty file, my simple latex file compiles without any warnings:

Basic Builder: running pdflatex...done.
running bibtex...done.
running pdflatex...done.
running pdflatex...done.

No errors. No warnings. No bad boxes.

What are these lines doing? Is there a way to fix them, so they do not cause the warning LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right every time I compile my simple file?

%we are repeating \bibcite command as defined in hyperref.sty
%so that we have it all together at one place.
\ifthenelse{\boolean{ABNThyperref}}{% not comment this, but the next two, to fix the warning
\renewcommand{\bibcite}[2]{%
 \@newl@bel{b}{#1}{\hyper@@link[cite]{}{cite.#1}{#2}}}%
4

abntex2cite.sty includes the following (which includes the lines you quoted):

%we are repeating \bibcite command as defined in hyperref.sty
%so that we have it all together at one place.
\ifthenelse{\boolean{ABNThyperref}}{%
\renewcommand{\bibcite}[2]{%
 \@newl@bel{b}{#1}{\hyper@@link[cite]{}{cite.#1}{#2}}}%

What this means is that the author(s) copied the definition in whichever version of hyperref.sty they happened to have at the time s/he/they wrote this. This is a Very Bad Idea Indeed because package code is not set in stone. Packages get bug fixes, updated to work with new code elsewhere, updated to include new features etc.

In this case, hyperref.sty now says

\ltx@IfUndefined{NAT@parse}{%
  \providecommand*\@extra@binfo{}%
  \providecommand*\@extra@b@citeb{}%
  \def\bibcite#1#2{%
    \@newl@bel{b}{#1\@extra@binfo}{%
      \hyper@@link[cite]{}{cite.#1\@extra@b@citeb}{#2}%
    }%
  }%
\gdef\@extra@binfo{}%
  \let\Hy@bibcite\bibcite
  \begingroup
    \@ifundefined{bbl@cite@choice}{}{%
      \g@addto@macro\bbl@cite@choice{%
        \let\bibcite\Hy@bibcite
      }%
    }%
  \endgroup
  \providecommand*{\@BIBLABEL}{\@biblabel}%
  \def\@lbibitem[#1]#2{%
    ...

It is not clear to me whether this is equivalent to the code in abntex2cite.sty but, given your experiences, I would guess not. (And even if it is equivalent now, it may not be in three months or three years.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.