I stumbled across the following strange behaviour. Every time that I include a lstlisting
block I get a warning:
destination with the same identifier (name{lstnumber.1}) has been already used, duplicate ignored
Here is a minimal working example:
\documentclass[a4paper,titlepage,onecolumn,twoside,12pt]{article}
\usepackage[utf8x, latin1]{inputenc} %unix-windows-compatible
\usepackage{listings}
\usepackage[pdfpagelabels=true
, hyperfigures
, bookmarksnumbered
, naturalnames
, plainpages=false
]{hyperref}
\begin{document}
\begin{lstlisting}[label=l1,caption=c1]
listing1
dsfkdsj
fdsf
fsdf
\end{lstlisting}
\begin{lstlisting}[label=l2, caption=c2]
listing2
sdfkdsf
\end{lstlisting}
\begin{lstlisting}[label=l2, caption=c2]
listing2
sdfkdsf
sdff
dsff
\end{lstlisting}
\end{document}
The resulting warnings are:
/mwe_latex/mwe.aux: LaTeX Warning: Label `l2' multiply defined.
/mwe_latex/mwe.tex: destination with the same identifier (name{lstnumber.1}) has been already used, duplicate ignored
/mwe_latex/mwe.tex: destination with the same identifier (name{lstnumber.2}) has been already used, duplicate ignored
/mwe_latex/mwe.tex: destination with the same identifier (name{lstnumber.1}) has been already used, duplicate ignored
/mwe_latex/mwe.tex: destination with the same identifier (name{lstnumber.2}) has been already used, duplicate ignored
/mwe_latex/mwe.tex: destination with the same identifier (name{lstnumber.3}) has been already used, duplicate ignored
/mwe_latex/mwe.tex: destination with the same identifier (name{lstnumber.4}) has been already used, duplicate ignored
/mwe_latex/mwe.tex: LaTeX Warning: There were multiply-defined labels.
It seems that the warnings correspond to the number of lines. Also I could set naturalnames
to false
and the warnings would be gone. But I don't know what the implications are.
naturalnames
? Remove that. And you have the labell2
twice... Usually the link anchor names should be computed byhyperref
, not LaTeX itself.\usepackage[utf8x, latin1]{inputenc} %unix-windows-compatible
is your file utf8 or latin1? it can not be both. I would use\usepackage[utf8]{inputenc}
unless you have good reason not to do that.