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.

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

1 Answer

up vote 9 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
@kryksyh please see my updated answer. – Gonzalo Medina May 19 '12 at 21:19
show 4 more comments

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.