1

I use listings and hyperref for a project where I want to skip line numbers on some listings. I'm using a \Suppressnumber-command a \Reactivatenumber-command (from Listings: Skip line number on current line). However, the \Suppressnumber-command produces the following error

pdfTeX warning (ext4): destination with the same identifier (name{lstnumber.-1.\\thelstnumber\040}) has been already used, duplicate ignored 

It also produces this warning for all subsequent listings including input and inline listings. For my project it means 60000 lines (out of 63000) in the log. What can I do to fix it?

MWE

\documentclass{article}

\usepackage{listings}
\lstset{language=[Sharp]C,escapeinside={(*@}{@*)}}

\let\origthelstnumber\thelstnumber
\makeatletter
\newcommand*\Suppressnumber{%
    \lst@AddToHook{OnNewLine}{%
        \let\thelstnumber\relax%
        \advance\c@lstnumber-\@ne\relax%
    }%
}
\makeatother

\usepackage{hyperref}

\begin{document}
   \begin{lstlisting}
       public void Main(){
           (*@ \Suppressnumber @*)
           int i = 0;
       }
   \end{lstlisting}
\end{document}
Zinoex
  • 111
  • your code works fine for me – Moriambar May 20 '17 at 10:31
  • It compiles. But if you check the *.log-file, you will see a destination with the same identifier-warning which just accumulates and produce an insane amount of log. – Zinoex May 20 '17 at 10:36
  • 1
    You should edit the question and state that it's not an error but a log warning: I did not understand that and thought it was a compilation error :) – Moriambar May 20 '17 at 10:37

0 Answers0