Pdfbookmark for abstract and table of contents (toc)

I am trying to set a bookmark of my abstract and my table of contents. The bookmark for the abstracts works fine but the bookmark for the toc links to the abstract instead to the toc. If I remove

\pdfbookmark[section]{Abstract}{toc} 

the contents bookmark links fine to the toc...

I do not see where the mistake is and am thankful for any help!

Her is my MWE:

\documentclass{article} \usepackage{hyperref, bookmark}  \begin{document} %%%%%%%%%%%%%%%%%%% Abstract %%%%%%%%%%%%%%%%%% \cleardoublepage \phantomsection \pdfbookmark[section]{Abstract}{toc} \begin{abstract} \end{abstract}  %%%%%%%%%%%%%%%%%%% Contents %%%%%%%%%%%%%%%%%% \cleardoublepage \phantomsection \pdfbookmark[section]{\contentsname}{toc} \tableofcontents  %%%%%%%%%%%%%%%%%%% Chapters %%%%%%%%%%%%%%%%%% \cleardoublepage \section{Introduction} \cleardoublepage \section{Sec 2} \cleardoublepage \section{Sec 3}  \end{document} 

Replay

The last argument of \pdfbookmark becomes the main part of the intern anchor name for the bookmark. The two invocations of \pdfbookmark use both toc with the same level. Therefore the document has two destinations with the same name, but a destination name must be unique. Thus instead of toc, the first \pdfbookmark could use abstract. Also \phantomsection is not needed, because \pdfbookmark already creates an anchor.

Example:

\documentclass{article}
\usepackage{hyperref, bookmark}

\begin{document}
%%%%%%%%%%%%%%%%%%% Abstract %%%%%%%%%%%%%%%%%%
\cleardoublepage
\pdfbookmark[section]{Abstract}{abstract}
\begin{abstract}
\end{abstract}

%%%%%%%%%%%%%%%%%%% Contents %%%%%%%%%%%%%%%%%%
\cleardoublepage
\pdfbookmark[section]{\contentsname}{toc}
\tableofcontents

%%%%%%%%%%%%%%%%%%% Chapters %%%%%%%%%%%%%%%%%%
\cleardoublepage
\section{Introduction}
\cleardoublepage
\section{Sec 2}
\cleardoublepage
\section{Sec 3}

\end{document}

Category: hyperref Time: 2016-07-29 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.114 (s). 12 q(s)