该章节在书签中出现两次

该章节在书签中出现两次

首先,抱歉我的英语不好。我正在设计一本书,bookmark在编译 file.tex 到 file.pdf 时遇到了问题。章节出现了两次。在我的代码中,我不想列出章节,但我希望它们出现在中,tableofcontents所以我不得不使用\addcontentsline{toc}{chapter}{chapter name}将它们添加到索引中,但这会导致重新添加章节bookmark

此外,我还使用该包bookmark来链接我想要的页面中的章节。我该怎么做才能显示目录和 file.pdf 书签中的章节一次?

这是我的代码:

\documentclass{book} 
...  
\usepackage{bookmark}

\begin{document}

\chapter*{Presentación}   % Presentation of the book
\bookmark[page=2,level=0]{Presentación}  

\tableofcontents

\chapter*{Aspectos téncicos} % From here they appear in the index 
\bookmark[page=4,level=0]{Aspectos téncicos}
\addcontentsline{toc}{chapter}{Aspectos téncicos}

\end{document}

答案1

您不需要为所有章节附加书签说明,也不需要\addcontentsline

\documentclass[12pt,letterpaper,openright]{book} 
\usepackage[utf8]{inputenc} 
\usepackage[spanish,es-tabla]{babel}

\usepackage{bookmark}

\usepackage{titlesec} 
\usepackage{titletoc} 

\titleformat{\chapter}[display]{\Huge\bfseries}{\chaptertitlename\ \thechapter}{0pt}{}
\titleformat{\section}{\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\large\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\normalsize\bfseries}{\thesubsubsection}{1em}{}
\titlespacing*{\chapter}{0pt}{-60pt}{10pt}[-60pt]
\titlespacing*{\section}{0pt}{28pt plus 1pt minus 2pt}{14pt plus 2pt}
\titlespacing*{\subsection}{0pt}{14pt plus 1pt minus 2pt}{14pt plus 2pt}
\titlespacing*{\subsubsection}{0pt}{14pt plus 1pt minus 2pt}{14pt plus 2pt}

% Change \frontmatter and \mainmatter not to reset the numbering
\makeatletter
\renewcommand\frontmatter{%
  \cleardoublepage
  \@mainmatterfalse
  \pagestyle{empty}% no printed page numbers
}
\renewcommand\mainmatter{%
  \cleardoublepage
  \@mainmattertrue
  \pagestyle{headings}% change to suit
}
\makeatother

\begin{document}
\frontmatter

\bookmark[page=\thepage,level=0]{Portada} 
%\input{./portada.tex}   % Bookcover
{\Huge COVER}\clearpage %%%% <--- I don't have your file

%%% This doesn't go in the TOC, so a \bookmark is necessary   
\chapter*{Presentación}   % Presentation of the book
\bookmark[page=\thepage,level=0]{Presentación}  

\tableofcontents

\mainmatter

\chapter{Aspectos técnicos}   %First chapter from here I wish to appear in the tableofcontents

\end{document}

我修改了\frontmatter\mainmatter命令,以便不重置编号。\pagenumbering{gobble}当涉及时,使用不起作用hyperref,但它足以消除正常的页面样式并在重置它\mainmatter

(我还省略了不必要的包,请按照您的喜好填写。)

相关内容