我目前正在处理一个具有固定格式的文档,其中还包括多个具有相同编号的节和小节。
\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}
可悲的是,hyperref
我一点也不喜欢它,并反复抱怨它:
(./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) )
有什么方法可以消除警告?它在我正在处理的实际文档的编译过程中经常出现,使得其他警告不那么明显。
从其他帖子的答案来看,似乎没有办法手动抑制该特定警告……:(
答案1
要么使用hypertexnames=false
要么提供虚拟计数器来hyperref
做出“正确”的锚点,请参阅\tocless
命令。
我尝试通过另一种设置来提供更好的版本!
\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}