8

I use hyperref to create clickable PDF files. I have sections and subsections and they are all nicely in the PDF bookmarks. Now there are certain items in my document that I want to appear in the bookmarks but not within the hierarchy of the sections, because this is rather like a short glossary. Like the most important theorems in alphabetical order. I know I can create custom bookmarks using \pdfbookmark. They appear and clicking them puts me to the right page but they appear right where their page number puts them in the order of sections.

  1. How can I decide where the bookmark appears? I would like to have them below the regular ones and ordered alphabetically (I can do the ordering myself once I know how to assign positions).
  2. Ideally even: create a dummy bookmark called "glossary" where clicking does nothing but which has all the ones mentioned above hierarchically below it, so one is not overwhelmed by the number of bookmarks when one first opens the document.
  3. And even further: I usually use hyperref with option bookmarksopen=true, is it possible in my new scenario, to have all the regular bookmarks open, but the glossary one closed? that would be the dream state for my document.
3
  • 2
    I would use the bookmark package. See also Customize PDF bookmarks. Commented Apr 29, 2011 at 7:27
  • what's the difference between a comment and an answer? anyhow, i found this thread and other references to this package before, but i didnt see a way to use it to achieve what i want. maybe you could be so kind as to give me an example line which adds say a reference to the toc as last bookmark.
    – peter
    Commented Apr 29, 2011 at 9:34
  • I posted it as a comment because it wasn't a full solution and therefore no answer. I didn't use bookmark before, otherwise I would posted an answer with some good example code. Commented Apr 29, 2011 at 9:37

1 Answer 1

5

Adding bookmarks in "random" order is easy. But I don't know how to add a bookmark without action. Using a not-existing destinition doesn't look very clean to me.

\documentclass{article}
\usepackage{bookmark}
\begin{document}
 \bookmark[dest=None,open=true]{Open}
 \bookmarksetup{rellevel=1}
 \bookmark[dest=a]{A} %
 \bookmark[dest=b]{B}


 \bookmark[dest=None,startatroot,open=false]{Closed}
 \bookmarksetup{rellevel=1}
 \bookmark[dest=a]{A} %
 \bookmark[dest=b]{B}

b\hypertarget{b}{}%

\newpage
a\hypertarget{a}{}%
\end{document}

Edit: I asked Heiko about the "dummy" bookmark. His answer:

I do not know an official way (if there is any). Candidates: * named action with non-existing name * empty javascript action * an empty action object? * ...

And standards such as PDF/A might forbid much of the fun.

5
  • thanks, it basically works. it has to be mentioned that the bookmarks package has to be imported after the hyperref package (otherwise i got strange errors). the \hypertarget targets seem to be a bit off, for me, the one pointing at a lands a bit too high, the one pointing at b is a bit too low so that b isnt even visible. if you have no spontaneous idea about this, i will create a minimal example.
    – peter
    Commented Apr 29, 2011 at 14:49
  • also i realize now that i abstracted my problem a bit wrongly. i need to be able to create the bookmarks in the same place in the code where the targets are defined, but tell them where (i.e. under which parent-bookmark) they should go. should i create a new question for this?
    – peter
    Commented Apr 29, 2011 at 14:54
  • This will probably not work. You will have to give the \bookmark commands in the correct order. Commented Apr 29, 2011 at 15:35
  • i fixed the issue of the hypertargets being off: what is referenced is actually the content of the empty brackets, putting the targets before the a resp. b (still with empty brackets), they are hit exactly.
    – peter
    Commented Apr 30, 2011 at 7:44
  • I got a bit further: tex.stackexchange.com/questions/17050/…
    – peter
    Commented Apr 30, 2011 at 22:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .