LaTeX forum ⇒ Page LayoutBookmark do not point at the right location with pdfbookmark

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Tobias_Denmark
Posts: 18
Joined: Sun Jun 06, 2010 1:59 pm

Bookmark do not point at the right location with pdfbookmark

Postby Tobias_Denmark » Tue Sep 23, 2014 12:03 pm

I can not get the \pdfbookmark to point at the right location. In my own created list of appendices, the \addcontentsline point to the correct location. I have tried placing the \pdfbookmark line of code before, in-between and after \chapter. The same problem occur with \section and \subsection. Hope anyone can help me out here :?:

  1. \documentclass{book}
  2.  
  3. % remove entry to toc, but keep no./letter in chapter/section:
  4. \newcommand*{\nocontentsline}[3]{}
  5. \newcommand*{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
  6.  
  7. % chapter without toc entry, but listed in list of app and bookmarked:
  8. \newcommand*\appChap[1]{%
  9. \tocless%
  10. \chapter{\thechapter{}: #1}%
  11. \addcontentsline{app}{chapter}{\thechapter{}: #1}%
  12. \pdfbookmark[0]{\thechapter{}: #1}{#1}%
  13. }
  14.  
  15. % section, subsection and subsubsection:
  16. \newcommand*\appSec[1]{\tocless\section{#1}\addcontentsline{app}{section}{\thesection{}: #1}\pdfbookmark[0]{\thesection{}: #1}{#1}}
  17. \newcommand*\appSubSec[1]{\tocless\subsection{#1}\addcontentsline{app}{subsection}{\thesubsection{}: #1}\pdfbookmark[0]{\thesubsection{}: #1}{#1}}
  18. \newcommand*\appSubSubSec[1]{\tocless\subsubsection{#1}\addcontentsline{app}{subsubsection}{\thesubsubsection{}: #1}}
  19.  
  20. % make list of appendices:
  21. \makeatletter
  22. \newcommand*\listofappendices{\chapter{List of Appendices}\@starttoc{app}}
  23. \makeatother
  24.  
  25. \usepackage{appendix}
  26. \usepackage{hyperref}
  27. \usepackage{bookmark}
  28.  
  29. \begin{document}
  30. \frontmatter
  31. \phantomsection
  32. \pdfbookmark[0]{Table of Contents}{toc}
  33. \tableofcontents
  34. \listofappendices
  35. \mainmatter
  36. \chapter{Chapter one}
  37. \chapter{Chapter two}
  38. \appendix
  39. \cleardoublepage
  40. \bookmarksetupnext{level=part}
  41. \addappheadtotoc % adds a title to the table of contents
  42. \appendixpage % adds a separate title “Appendices” above the first appendix
  43. \begin{appendices}
  44. \appChap{Appendix a}
  45. ...(contents of appendix a)...
  46. \appSec{Appendix a - section 1}
  47. ...(contents of appendix one)...
  48. \appSubSec{Appendix a - subsection 1}
  49. ...(contents of appendix one)...
  50. \appSubSubSec{Appendix a - subsubsection 1}
  51. ...(contents of appendix one)...
  52. \appChap{Appendix b}
  53. ...(contents of appendix two)...
  54. \appSec{Appendix b - section 1}
  55. ...(contents of appendix two)...
  56. \end{appendices}
  57. \backmatter
  58. \end{document}

Tags:

Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 3 guests