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.

There is a way to make TOC using \tableofcontents, but there are only sections and subsections.

How can I get list of all frames without using sectioning?

share|improve this question
    
Welcome! What do you want to have as content? Only the frame numbers? –  Marco Daniel May 19 '12 at 16:52
    
No, frame numbers and titles. –  kryksyh May 19 '12 at 17:08
    
Or simple itemized list. I guess I can write shell script but wonder if it can be done by latex. –  kryksyh May 19 '12 at 17:37

3 Answers 3

up vote 12 down vote accepted

Here's a simple approach using the \@starttoc command through the newly defined \listofframes command; the new list will have extension .lbf. \addtobeamertemplate was used so that the frametitle command writes the desired information (frame number and title) to the .lbf file. The list is created issuing \listofframes:

\documentclass{beamer}

\makeatletter
\newcommand\listofframes{\@starttoc{lbf}}
\makeatother

\addtobeamertemplate{frametitle}{}{%
  \addcontentsline{lbf}{section}{\protect\makebox[2em][l]{%
    \protect\usebeamercolor[fg]{structure}\insertframenumber\hfill}%
  \insertframetitle\par}%
}

\begin{document}

\begin{frame}
\frametitle{List of Frames}
\listofframes
\end{frame}

\begin{frame}
\frametitle{Test Frame One}
test
\end{frame}

\begin{frame}
\frametitle{Test Frame Two}
test
\end{frame}

\end{document}

Here's the resulting List of Frames:

enter image description here

To facilitate control over which frames to include in the new list, you can use a boolean switch; in the following example I used \ifframeinlbf initially set to true; if you want to suppress some titled frame(s) from the list of frames, use \frameinlbffalse right before those frame(s) and then use \frameinlbftrue right after the frame(s) to activate inclusion in the list:

\documentclass{beamer}

\newif\ifframeinlbf
\frameinlbftrue
\makeatletter
\newcommand\listofframes{\@starttoc{lbf}}
\makeatother

\addtobeamertemplate{frametitle}{}{%
  \ifframeinlbf
  \addcontentsline{lbf}{section}{\protect\makebox[2em][l]{%
    \protect\usebeamercolor[fg]{structure}\insertframenumber\hfill}%
  \insertframetitle\par}%
  \else\fi
}

\begin{document}

\frameinlbffalse
\begin{frame}
\frametitle{List of Frames}
\listofframes
\end{frame}

\frameinlbftrue
\begin{frame}
\frametitle{Test Frame One}
test
\end{frame}

\begin{frame}
\frametitle{Test Frame Two}
test
\end{frame}

\end{document}
share|improve this answer
    
Thank you! This works perfectly! –  kryksyh May 19 '12 at 20:47
    
@kryksyh: You're welcome. Don't forget, after a sensible wait, to mark the answer (this one or another one that might eventually appear) that best solved your problem as accepted. In case of doubt, please see How do you accept an answer?. –  Gonzalo Medina May 19 '12 at 20:51
    
Oh, that faded tick on the left is hard to find first time. Done. Thank you –  kryksyh May 19 '12 at 20:59
    
Now I have homework - remove from TOC contents slide itself :) –  kryksyh May 19 '12 at 21:09
1  
@SandroGržičić please feel free to open a follow up question, and add there a minimal example document (like the one in my example code) allowing us to reproduce the mentioned problem. –  Gonzalo Medina Jul 25 '13 at 14:06

i want to add some comments to the solution of Sandro:

The code was not working for me until i changed the line

 \addcontentsline{lbf}{section}{\protect\makebox[2em][l]{%

to

\addcontentsline{lbf\thesection}{section}{\protect\makebox[2em][l]{%

Further, the idea with the link is good, but if you have uncover-effects, e.g. with pause, uncover, ..., the framenumber does not correspond with the page number. Thus i changed the line

\protect\hyperlink{page.\insertframenumber}\insertframetitle\par}%

to

\protect\hyperlink{page.\insertpagenumber}\insertframetitle\par}%

Hope i was able to contriubte something!

share|improve this answer

In addition to Gonzalo Medina's answer, if you want frame titles to link to page numbers, use this code just before the \insertframetitle:

\protect\hyperlink{page.\insertframenumber}

So the full code is:

\addtobeamertemplate{frametitle}{}{%
  \ifframeinlbf
  \addcontentsline{lbf}{section}{\protect\makebox[2em][l]{%
    \protect\usebeamercolor[fg]{structure}\insertframenumber\hfill}%
  \protect\hyperlink{page.\insertframenumber}\insertframetitle\par}%
  \else\fi
}

The above requires the hyperref package, so make sure you include it.

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.