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.

The hyperref package automatically creates a list of "Acrobat bookmarks" – a table-of-contents tree that is not part of the printed document, but can be accessed in a PDF reader (typically it is displayed in a side panel next to the document).

All sections, subsections, etc. are automatically added to the list. However, I would like to add additional entries.

I have a somewhat tricky situation: At the very end of my document, I have \clearpage, which is followed by a number of full-page floating figure environments (and nothing else). I would like to have a bookmark that looks like \subsection and takes me to the first page with a full-page float (the page right after \clearpage).

How can I do that?

If I add something like \phantomsection \addcontentsline{toc}{subsection}{Figures} \null between \clearpage and the first full-page float, I will have an additional empty page in my document.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I can't figure out why it doesn't work to just do what you're doing, or why putting the \addcontentsline inside a \AtNextShipout doesn't work. That said, it seems to work if you put it in the figures.

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{asdf}
asdf
\section{qwer}
\clearpage
\begin{figure}[p]
\phantomsection
\addcontentsline{toc}{subsection}{Figures}
\noindent
\rule{4in}{6in}%
\caption{X}
\end{figure}
\begin{figure}[p]
\noindent
\rule{4in}{6in}%
\caption{Y}
\end{figure}
\begin{figure}[p]
\noindent
\rule{4in}{6in}%
\caption{Z}
\end{figure}
\end{document}

Edit:
Actually, just after I posted this, I had a thought. The \write gets put on the main vertical list, but this is never shipped out. Yeah. Add a \clearpage adsf after the last figure with the \phantom\addcontentsline... before the figures and sure enough, the bookmark is to the text after the figures.

I'm still not sure why it doesn't work \AtNextShipout. I'd have to check the package again, but I'm pretty sure that does something like changing \shipout into \afterassignment\shipouthook\setbox0= and then the \shipouthook inserts the material into the box and uses \aftergroup to perform the real shipout once the \vbox in \shipout\vbox{...} from \@outputpage is closed.

share|improve this answer

Use a bookmark which takes you to the target.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{hyperref}
\begin{document}
\section{foo}
bar
\newpage
\section{Another Section}
\clearpage
\begin{figure}
\hypertarget{figures}{}
\pdfbookmark[2]{Figures}{figures}
\includegraphics[width=\textwidth,height=0.8\textheight]{foobar}
\caption{my caption}
\end{figure}

\begin{figure}
\includegraphics[width=\textwidth,height=0.8\textheight]{foobar}
\caption{my caption}
\end{figure}

\begin{figure}
\includegraphics[width=\textwidth,height=0.8\textheight]{foobar}
\caption{my caption}
\end{figure}
\end{document}
share|improve this answer

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.