# \pdfbookmark hyperlink aims to low with \includepdf

I'm trying to use pdfTeX to bring together several PDF documents and use the bookmarks feature of Adobe/Preview to supply a hyperlinking structure in a sidebar window. When I try this with multiple PDF files at multiple levels of indentation, the hyperlinking structure "works", but some of the links aim too low! Check out the following:

\documentclass[11pt]{article}%
\usepackage{pdfpages}%
\usepackage{bookmark}%

\begin{document}%
\pdfbookmark[1]{Test 0}{test0}%

\pdfbookmark[2]{Test 1}{test1}%

\pdfbookmark[3]{Test 2}{test2}%

\pdfbookmark[1]{Test 3}{test3}%
\end{document}%


Use your favorite PDF files for Testpdf files 0, 1, 2 and 3. Compile this and then open the resulting document in either Adobe Reader or Preview and click on the bookmarks. The bookmarks for Test 0 and Test 3 work fine -- you can see the top 1.5 cm of your document -- which is what I want. However the bookmarks Test 1 and Test 2 aim too low cutting off the top of each of these pages. Any ideas how to fix this behavior? (Is it intentional?)

I'm preparing an important document and I do not want to annoy my reader (or they won't be incline to decide in my favor)!

-
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Martin Scharrer May 4 '12 at 19:43

The following should fix it, although I'm not sure whether it would break other things.

\makeatletter
\renewcommand*{\pdfbookmark}[3][0]{%
\bookmark[level=#1,dest={#3.1}]{#2}% originally dest={#3.#1}
\hyper@anchorstart{#3.1}\hyper@anchorend% originally #3.#1
}
\makeatother


to your document preamble after loading bookmark. The above modification fixes the destination of the hyper target to #3.1 (level 1), while the bookmark level is still dependent on the first (optional argument) and internally set using level=#1.

This is most certainly intended. Level 1 (and 0) bookmarks typically form part of full-page styles (like a \chapter or \part), while lower-level bookmarks occur in the middle of the page (like \section and \subsection). To see why this is the case, include the showframe package in your preamble. The hyperlinks from the bookmarks at levels 2 and 3 just to the first line of the text block, indicated by the border made by showframe.

-
Werner: This works great! Thanks so much! –  Will May 5 '12 at 2:50