4

I am currently working on a document with fixed format, which also includes multiple sections and subsections with the same numbering appearing in it.

\documentclass[12pt,a4paper]{memoir}

\usepackage[usehighlevels]{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection,paragraph}
\alnumsecstyle{aaaa}
\surroundarabic[{.}][]{}{}
\otherseparators{1}
\alnumsecstyle{aaaa}

\usepackage[colorlinks,plainpages]{hyperref}
\hypersetup{urlcolor=blue, citecolor=blue, linkcolor=blue}

\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}

\begin{document}

\maxtocdepth{subsubsection}
\tocless\tableofcontents
\clearpage

\section{Introduction}
\subsection{...}
\subsubsection{...}
\subsubsection{...}
\subsection{...}
\subsubsection{...}


\section{Description of the parts}

\section*{Part A}
\phantomsection\addcontentsline{toc}{subsection}{Part A}
\tocless\subsection{On Part A}
\tocless\subsubsection{all the numbers are fixed}
\tocless\subsubsection{I have no power on the numbering}
\tocless\subsubsection{so this has to be 2.1.3}
\tocless\subsubsection{and this has to be 2.1.4}

\setcounter{subsection}{0}
\section*{Part B}
\phantomsection\addcontentsline{toc}{subsection}{Part B}
\tocless\subsection{On Part B}
\tocless\subsubsection{all the numbers are fixed}
\tocless\subsubsection{I have no power on the numbering}
\tocless\subsubsection{so this has to be 2.1.3}
\tocless\subsubsection{and this has to be 2.1.4}

\end{document}

Sadly, hyperref doesn't like it one bit and complains repeatedly about it:

(./Proposal.out) (./Proposal.out) (./Proposal.toc) [1{/usr/local/texlive/2015/t
exmf-var/fonts/map/pdftex/updmap/pdftex.map}] [2pdfTeX warning (ext4): destinat
ion with the same identifier (name{subsection.0.2.1}) has been already used, du
plicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                              \fi \fi 
l.70 \end{document}
               pdfTeX warning (ext4): destination with the same identifier 
(name{subsubsection.0.2.1.1}) has been already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                              \fi \fi 
l.70 \end{document}
               pdfTeX warning (ext4): destination with the same identifier 
(name{subsubsection.0.2.1.2}) has been already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                              \fi \fi 
l.70 \end{document}
               pdfTeX warning (ext4): destination with the same identifier 
(name{subsubsection.0.2.1.3}) has been already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                              \fi \fi 
l.70 \end{document}
               pdfTeX warning (ext4): destination with the same identifier 
(name{subsubsection.0.2.1.4}) has been already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                              \fi \fi 
l.70 \end{document}
               ] (./Proposal.aux) )

Is there a way I can get rid of the warning? It appears quite often during compilation in the actual document I am working on, making other warnings far less visible.

From the answers in the other threads there doesn't seem to be a way to manually suppressing that particular warning... :(

  • 1
    A last resort method: hypertexnames=false in \hypersetup. The hyperref anchors are confused by this! – user31729 Dec 9 '15 at 16:39
  • A better solution needs details about the reasonings why some parts shouldn't be 'toc'ed. – user31729 Dec 9 '15 at 16:56
  • How the TOC should look is also fixed by a given template that I must follow, which requires that some subsections and subsubsections do not appear in it. – jpb Dec 10 '15 at 22:20
  • If you don't need numbered sections etc. and they should not appear in the ToC as well, then use \section*{...} etc. – user31729 Dec 10 '15 at 22:22
4

Either use hypertexnames=false or provide a dummy counter to let hyperref make 'correct' anchors, see the \tocless command.

I try to provide a better version with another setup!

\documentclass[12pt,a4paper]{memoir}

\usepackage[usehighlevels]{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection,paragraph}
\alnumsecstyle{aaaa}
\surroundarabic[{.}][]{}{}
\otherseparators{1}
\alnumsecstyle{aaaa}

\usepackage[colorlinks,plainpages]{hyperref}
\hypersetup{urlcolor=blue, citecolor=blue, linkcolor=blue}%,hypertexnames=false}

\newcounter{dummycounter}
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\stepcounter{dummycounter}\bgroup\let\theHsection\thedummycounter\let\addcontentsline=\nocontentsline#1{#2}\egroup}

\begin{document}

\maxtocdepth{subsubsection}
\tocless\tableofcontents
\clearpage

\section{Introduction}
\subsection{...}
\subsubsection{...}
\subsubsection{...}
\subsection{...}
\subsubsection{...}


\clearpage
\section{Description of the parts}

\section*{Part A}
\phantomsection\addcontentsline{toc}{subsection}{Part A}
\tocless\subsection{On Part A}
\tocless\subsubsection{all the numbers are fixed}
\tocless\subsubsection{I have no power on the numbering}
\tocless\subsubsection{so this has to be 2.1.3}
\tocless\subsubsection{and this has to be 2.1.4}

\clearpage

\setcounter{subsection}{0}
\section*{Part B}
\phantomsection\addcontentsline{toc}{subsection}{Part B}
\tocless\subsection{On Part B}
\tocless\subsubsection{all the numbers are fixed}
\tocless\subsubsection{I have no power on the numbering}
\tocless\subsubsection{so this has to be 2.1.3}
\tocless\subsubsection{and this has to be 2.1.4}

\end{document}

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.