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.

Using \usepackage{hyperref}and the \pdfbookmark[0]{...}{...} command you can place a PDF bookmark just before the index page generated with \printindex (Sometimes it will point to the empty page before the index.) How can one place a bookmark exactly to the Index title?


After reading the answers so far, I have to refine the question a bit it seems.

I have now noticed two things that escaped me at first:

  • The index is always placed on an odd page. (May be common knowlegde but wasn't for me :-)
  • If the even page before the index has text on it, then the bookmark placed before \printindex will point to the index page. If there is an empty (even) page inserted, then the bookmark will point to this empty page instead of the index page.

I also should have provided the construct that places the index in our custom document class:

 \AtEndDocument{
   \pdfbookmark[0]{\indexname}{bookmarkForTheIndex}
   \printindex
 }

Note that I found something talking about AtEndDocument and the index, but I fear I do not quite understand it ... http://www.tug.org/TUGboat/Articles/tb19-1/tb58works.pdf

share|improve this question

2 Answers 2

up vote 2 down vote accepted

\printindex starts a theindex environment, which by default calls \twocolumn, which - and this causes your problem - starts a new page. The following should do the trick:

\cleardoublepage
\pdfbookmark[0]{\indexname}{idx}
\printindex

(You could also simply include the index in your table of contents.)

share|improve this answer
    
Although I haven't tested it on a MWE, this doesn't work for me. The bookmarks in the toc and the pdf bookmarks both hyperlink to the first entry in the index, not at the \indexname header as it should. Somehow there's some magic tucked within your idxlayout package. I'll have to disassemble it someday. In any event, it works for me. I guess I owe you a good Aussie "thanks mate!" –  Geoffrey Jones Sep 8 '10 at 16:40
    
Yes, I was afraid that my hack wouldn't get the exact vertical positioning right. But at least the bookmark points to the correct page. –  lockstep Sep 8 '10 at 16:46
    
Inserting \cleardoublepage (In addition to our AtEndDocument) does indeed do the trick! Now the bookmark will always be placed correctly to the index page, regardless if there's an empty page before. –  Martin Sep 9 '10 at 7:18

This one's easy, or at least it finally was for me. It used to drive me crazy. I'd injected every piece of code I could imagine into \printindex to try to get it right. I came very close with careful use of hyperref \phantomsection along with a customised \Hy@raisedlink. But it never felt completely perfect. Then I discovered our good friend lockstep's idxlayout package, using it like this: \usepackage[unbalanced,totoc]{idxlayout}. Now everything is sweet.

share|improve this answer
2  
I feel a bit sheepish now. ;-). –  lockstep Sep 8 '10 at 16:24
    
I have not tried the idxlayout package since it's not part of our internal MikTeX distribution and adding it would be a major administrative headache at the moment. –  Martin Sep 9 '10 at 7:19
    
@Martin, I won't try and persuade you. :)) –  Geoffrey Jones Sep 9 '10 at 10:27

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.