3

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}%
\includepdf[pages={-},link,linkname=test0,linkfit=FitH]{Testpdf0.pdf}%

\pdfbookmark[2]{Test 1}{test1}%
\includepdf[pages={-},link,linkname=test1,linkfit=FitH]{Testpdf1.pdf}%

\pdfbookmark[3]{Test 2}{test2}%
\includepdf[pages={-},link,linkname=test2,linkfit=FitH]{Testpdf2.pdf}%

\pdfbookmark[1]{Test 3}{test3}%
\includepdf[pages={-},link,linkname=test3,linkfit=FitH]{Testpdf3.pdf}%
\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)!

1

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

Add

\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.

1

\pdfbookmark hyperlink seem to aim to the top of the printable area.

\usepackage{geometry}
\newgeometry{top=0cm}

solved it for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.