4

Compiling the following example file:

\documentclass{aa}
\usepackage{hyperref}
\begin{document}
\section{Introduction}
Aaaa bbbb~\cite{Smith_2005} cccc.
\bibliographystyle{aa}
\bibliography{biblio}
\end{document}

shows the warning:

.../test.tex:15: Package hyperref Warning: Suppressing link with empty target on input line 15.

I compile with:

$ latexmk test.tex

my LaTeX version is:

$ latex
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=latex)

The biblio.bib file looks like this:

@ARTICLE{Smith_2005,
    author = {{Smith}, N.~V.},
    journal = {AAA},
    year = 2005,
    month = sep,
    volume = 440,
    pages = {403-408},
}

and the other two files needed to compile are here: aa.cls, aa.bst.

Disabling the hyperref package makes the warning go away, but I need it to be enabled. The final PDF looks fine, but I wonder why this warning appears since I don't remember seeing it before.

  • Your input file doesn't have 16 lines. So perhaps this message doesn't pertain to the example code? – Werner Dec 26 '16 at 19:47
  • There was a comment that I removed for clarity. It is fixed now. – Gabriel Dec 26 '16 at 19:48
  • 1
    If you change aa to article does the warning persist? – Hugh Dec 27 '16 at 1:14
  • No, it goes away. – Gabriel Dec 27 '16 at 2:09
6

The class stores the last page number as a reference using LastPage, written as part of \end{document} (comment added):

\renewcommand*\enddocument{%
   \let\AtEndDocument\@firstofone
   \@enddocumenthook
   \clearpage
   \advance\c@page \m@ne
   \immediate\write\@auxout{\string\newlabel{LastPage}{{\thepage}{\thepage}{}{}{}}}
   % ^^^^ This writes the (last) page number as a \label to the .aux
   \@checkend{document}%
   \clearpage
   \begingroup
     \if@filesw
       \immediate\closeout\@mainaux
       \let\@setckpt\@gobbletwo
       \let\@newl@bel\@testdef
       \@tempswafalse
       \makeatletter \input\jobname.aux
     \fi
     \@dofilelist
     \ifdim \font@submax >\fontsubfuzz\relax
       \@font@warning{Size substitutions with differences\MessageBreak
                  up to \font@submax\space have occurred.\@gobbletwo}%
     \fi
     \@defaultsubs
     \@refundefined
     \if@filesw
       \ifx \@multiplelabels \relax
         \if@tempswa
           \@latex@warning@no@line{Label(s) may have changed.
               Rerun to get cross-references right}%
         \fi
       \else
         \@multiplelabels
       \fi
     \fi
   \endgroup
   \deadcycles\z@\@@end}

Note that the \newlabel is written with 5 arguments. However, arguments 3, 4 and 5 are empty. This is to accommodate regular, non-hyperref \labels which only require two arguments, as well as when hyperref is loaded (which writes \labels with 5 arguments).

This LastPage reference is used in the footer throughout the document via this macro (line 425):

\newcommand*\aa@pageof{, page \thepage{} of \pageref{LastPage}}

While this works in general, hyperref uses the additional arguments (empty in this case) to identify markers for the last page as a hyperlink/jump. Since they're empty, hyperref ignores the hyperlink and merely prints the (page) reference (together with a warning).

You can avoid this warning by changing the \pageref to \pageref*; add the following to your preamble:

\makeatletter
\renewcommand*\aa@pageof{, page \thepage{} of \pageref*{LastPage}}
\makeatother

Alternately, make all \pagerefs default to hyperlink-less references:

\let\oldpageref\pageref
\renewcommand{\pageref}{\oldpageref*}

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.