10

When working with a large beamer document, it is convenient to use \includeonlyframes{foo, bar, baz} to focus on a few specific slides at a time. However, one also needs to change it each time to include the labels of the slides that they want.

Instead, is it possible to use a wild card to pick out the slides? For example, I prefix the labels for all my slides with "SectionName", which is the section that slide is in. So a typical frame would look like:

\section{Introduction}
\begin{frame}[label=IntroSlide1]
...
\end{frame}

I would like to be able to select all frames in the introduction section by doing something like \includeonlyframes{Intro*} (the syntax can be changed to suit ease of programming, as long as the functionality is possible). Is this possible, and if so, how should I go about implementing it?

1 Answers1

6

I modified the syntax a bit to make it easier, -* denotes the wild card and the individual labels that match the wildcard have to have - in their name.

\documentclass{beamer}
\includeonlyframes{Intro-*,Sss-Slide2}

\makeatletter
\def\beamer@checkifinlist#1,#2\relax{%
\def\beamer@temp{#1}%
\let\b@name\beamer@againname
\b@star@test#1\relax-*!\relax\count@
\ifx\beamer@temp\b@name
\else
  \def \beamer@temp {#2}%
  \ifx\beamer@temp\@empty
    \gdef\beamer@whichframes{all:0}%
  \else
    \beamer@checkifinlist#2\relax
  \fi
\fi }

\def\b@star@test#1-*#2\relax#3\count@{%
\ifx\\#2\\%
\def\beamer@temp{#1}%
\expandafter\b@dash@test\beamer@againname-\valign\relax
\fi}

\def\b@dash@test#1-#2#3\relax{%
\ifx\valign#2%
\else
\def\b@name{#1}%
\fi}
\makeatother
\begin{document}
\begin{frame}[label=Intro-Slide1]
AAA
\end{frame}

\begin{frame}[label=Intro-Slide2]
BBB
\end{frame}

\begin{frame}[label=Sss-Slide1]
CCC
\end{frame}
\begin{frame}[label=Sss-Slide2]
DDD
\end{frame}

\end{document}

produces slides AAA BBB and DDD the first two from the Intro-* wildcard.

David Carlisle
  • 757,742