Three pieces of code are given below
- Subsections visible only when section entry revealed
- Subsections visible once only after section entry is revealed
- Subsections only visible for current section
Subsections visible only when section entry revealed
The following is very close to what you ask - the subsections will appear on the same slide as the corresponding section is revealed rather than on the slide after. See the section below, for how to get the other behaviour. The screen shots are for the second and third views of the contents page:
\documentclass{beamer}
\usetheme{Warsaw}
\makeatletter
\def\beamer@tocaction@only#1{\only<.(1)>{\usebeamertemplate**{#1}}}
\define@key{beamertoc}{subsectionsonly}[]{\beamer@toc@subsectionstyle{show/only}\beamer@toc@subsubsectionstyle{show/shaded/hide}}
\makeatother
\begin{document}
\AtBeginSection[]{\begin{frame}{Outline}
\tableofcontents[subsectionsonly, pausesections]
\end{frame}}
\section{One}
\begin{frame}
\frametitle{ff}
\end{frame}
\section{Two}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Two a}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Two b}
\begin{frame}
\frametitle{ff}
\end{frame}
\section{Three}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Three a}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Three b}
\begin{frame}
\frametitle{ff}
\end{frame}
\end{document}
The code adds an extra key type only
to effect the insertion of an appropriate \only
overlay command. This is packaged up in a new key subsectionsonly
to \tableofcontents
.
Subsections visible once only after section entry is revealed
Inserting an extra pause between the display of the section and that of the subsections, is a bit more involved. One needs to rewrite the functions \beamer@tableofcontents
and \beamer@subsectionintoc
. This is probably best done via patching of the commands, as below. The screeshots are for the first page revealing section 3 and for the next page:
\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{etoolbox}
\makeatletter
\def\beamer@tocaction@only#1{\only<.(1)>{\usebeamertemplate**{#1}}}
\define@key{beamertoc}{subsectionsonly}[]{\beamer@toc@subsectionstyle{show/only}\beamer@toc@subsubsectionstyle{show/shaded/hide}}
\newif\ifbeamer@pausebeforesubsections
\define@key{beamertoc}{pausebeforesubsections}[true]{\beamer@pausebeforesubsectionstrue}
\patchcmd{\beamer@tableofcontents}{\beamer@pausesectionsfalse}%
{\beamer@pausesectionsfalse\beamer@pausebeforesubsectionsfalse}{}{}
\patchcmd{\beamer@subsectionintoc}{\ifbeamer@pausesubsections\pause\fi}%
{\ifbeamer@pausesubsections\pause\else%
\ifbeamer@pausebeforesubsections\ifnumequal{#2}{1}{\pause}{}\fi\fi}{}{}
\makeatother
\begin{document}
\begin{frame}{Outline}
\tableofcontents[subsectionsonly,pausebeforesubsections,pausesections]
\end{frame}
\section{One}
\begin{frame}
\frametitle{ff}
\end{frame}
\section{Two}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Two a}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Two b}
\begin{frame}
\frametitle{ff}
\end{frame}
\section{Three}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Three a}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Three b}
\begin{frame}
\frametitle{ff}
\end{frame}
\end{document}
The above code includes that of the first example and adds a new option pausebeforesubsections
, which inserts a \pause
before the block of subsections. This is only necessary if pausesubsections
is not set. By default pausebeforesubsections
is set to false.
Subsections only visible for current section
Use the hideothersubsections
option. The code below gives the following table of contents at the beginning of section three, even though section two has subsections:
\documentclass{beamer}
\usetheme{Warsaw}
\begin{document}
\AtBeginSection[]{\begin{frame}{Outline}
\tableofcontents[hideothersubsections, pausesections]
\end{frame}}
\section{One}
\begin{frame}
\frametitle{ff}
\end{frame}
\section{Two}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Two a}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Two b}
\begin{frame}
\frametitle{ff}
\end{frame}
\section{Three}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Three a}
\begin{frame}
\frametitle{ff}
\end{frame}
\subsection{Three b}
\begin{frame}
\frametitle{ff}
\end{frame}
\end{document}
See section 10.5 of the beamer manual for further options to control what is and is not visible.
Add the following to your preamble.
\definecolor{lightgr}{rgb}{0.7 0.7 0.7}
\makeatletter
\newcount\beamer@sectionstartframe
\newcount\beamer@sectionendframe
\beamer@sectionstartframe=1
\apptocmd{\beamer@section}{\addtocontents{nav}{\protect\headcommand{%
\protect\beamer@sectionframes{\the\beamer@sectionstartframe}{\the\c@framenumber}}}}{}{}
\apptocmd{\beamer@section}{\beamer@sectionstartframe=\c@framenumber\advance\beamer@sectionstartframe by1\relax}{}{}
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
{\noexpand\headcommand{\noexpand\beamer@sectionframes{\the\beamer@sectionstartframe}{\the\c@framenumber}}}}}{}{}
\def\beamer@startframeofsection{1}
\def\beamer@endframeofsection{1}
\def\beamer@sectionframes#1#2{%
\ifnum\c@framenumber<#1%
\else%
\ifnum \c@framenumber>#2%
\else%
\gdef\beamer@startframeofsection{#1}%
\gdef\beamer@endframeofsection{#2}%
\fi%
\fi%
}
\newcommand\insertsectionstartframe{\beamer@startframeofsection}
\newcommand\insertsectionendframe{\beamer@endframeofsection}
\def\beamertextwidth{\dimexpr 0.875 \textwidth\relax}
\makeatother
\addtobeamertemplate{footline}{%
\color{lightgr}% to color the progressbar
\rlap{\rule{\numexpr (\insertframenumber-\insertsectionstartframe)+1 \dimexpr \beamertextwidth/(\insertsectionendframe -\insertsectionstartframe+1) \relax}{3pt}}%
}%
The above code should create a section progressbar in the footline of each slide. Note that the above code does work properly if you create new frames inside the AtBeginSection
environment.
Best Answer
You can redefine the
headline
beamer template as defined inbeamerouterthemesmoothbars.sty
to use\insertsubsectionnavigationhorizontal
instead of the default\insertsubsectionhead
; something along these lines:Some zoomed images showing the headline for some frames in the first and second sections: