Tell me more ×
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 would like to have a beamer presentation in which every frame appears in the PDF table of contents (i.e. has a bookmark). My specific presentation only has sections, so all of the frames can appear as a "subsection" on the PDF. Note that I don't want to make a subsection for each frame.

One way to do that is make up a command that patches frametitle by calling the appropriate bookmark command of hyperref. Is there any better way?

share|improve this question
Just to clarify, you want them to show up on the frame containing the table of contents or do you want to see them in your PDF viewer's sidebar/listing? – Carsten Thiel May 3 '11 at 8:16
I want them to show up only on the PDF viewer's sidebar. – Yuval Filmus May 4 '11 at 13:15

1 Answer

up vote 10 down vote accepted

Here is a solution that patches an auxiliary macro in \frametitle, adding code that adds a table-of-contents line as if it were a subsection:

\documentclass{beamer}

\AtBeginSection{\frame{\tableofcontents[currentsection]}}

\usepackage{bookmark}
\usepackage{etoolbox}
\makeatletter
\apptocmd{\beamer@@frametitle}{
  % keep this line to add the frame title to the TOC at the "subsection level"
  \addtocontents{toc}{\protect\beamer@subsectionintoc{\the\c@section}{0}{#1}{\the\c@page}{\the\c@part}%
        {\the\beamer@tocsectionnumber}}%
  % keep this line to add a bookmark that shows up in the PDF TOC at the subsection level
  \bookmark[page=\the\c@page,level=3]{#1}
  }%
  {\message{** patching of \string\beamer@@frametitle succeeded **}}%
  {\message{** patching of \string\beamer@@frametitle failed **}}%
\makeatother


\begin{document}

\section{First Section}


\begin{frame}{First frame}\end{frame}

\begin{frame}{Second frame}\end{frame}

\section{Second Section}


\begin{frame}{Third Frame}\end{frame}

\begin{frame}{Fourth frame}\end{frame}


\end{document}

I had to dig around in beamerbasesection.sty to figure that out. But it seems to work.

EDIT. I put in the bookmarking this time. Rather than delete the code which does something you didn't ask for, I left it for you to comment out.

share|improve this answer
Having reread your question I am now not sure I answered it. I put the frame titles in the TOC of the document but it seems you just want bookmarks. – Matthew Leingang May 3 '11 at 9:28
See edits....... – Matthew Leingang May 3 '11 at 9:43

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.