Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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)!

share|improve this question
    
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

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
Werner: This works great! Thanks so much! –  Will May 5 '12 at 2:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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