2

Consider this MWE:

\documentclass{beamer}


\AtBeginSection[]{%
\begin{frame}<beamer>
\frametitle{Outline}
    \begin{minipage}{.25\textwidth}
        \tableofcontents[currentsection, hideothersubsections] % removing hideothersubsections solves the problem
    \end{minipage}
    \hfill
    \begin{minipage}{.55\textwidth}
        \begin{centering}
            \insertsectionhead
        \end{centering}

    \end{minipage}
\end{frame}
}

\begin{document}
\begin{frame}[shrink]{ToC}
\tableofcontents
\end{frame}

\section[aa]{AA}
\begin{frame}{A}
a   
\end{frame}

\section[bb]{BB}
\begin{frame}{B}
b
\end{frame}

\section{CC}
\begin{frame}{C}
c
\end{frame}

\section{DD}
\begin{frame}{D}
d
\end{frame}

\section[ee]{EE}
\begin{frame}{E}
e
\end{frame}

\section[ff]{FF}
\begin{frame}{F}
f
\end{frame}

\section[gg]{GG}
\begin{frame}{G}
g
\end{frame}


\section[hh]{HH}
\begin{frame}{H}
h
\end{frame}


\section[ii]{II}
\subsection[iii]{III}
\subsection[iv]{IV}
\subsection[v]{V}
\begin{frame}{I}
i
\end{frame}
\end{document}

I can fit the ToC in one page by choosing shrink; but the ToC at the beginning of every section does not fit in one page (one partial solution is to remove hideothersubsections so that all subsections will be expanded).

What I want:

At the beginning of each section, the present section will be at the middle of the page, all its subsections will be expanded. Only a few neighboring sections will be (partially) visible, none of the subsections from these sections will be expanded.

Any help will be appreciated.

2

The following displays +- 2 sections around the current section. If you want more of less sections, this number can be adjusted.

\documentclass{beamer}

\newcounter{start}
\newcounter{stop}

\AtBeginSection[]{%
\setcounter{start}{\thesection}
\setcounter{stop}{\thesection}
\ifnum\value{section}>1
    \ifnum\value{section}=2
        \addtocounter{start}{-1}%
    \else%
        \addtocounter{start}{-2}%
    \fi%
\fi%
\addtocounter{stop}{2}
\begin{frame}<beamer>
\frametitle{Outline}
    \begin{columns}[c]
        \begin{column}{.25\textwidth}
            \tableofcontents[sections=\thestart-\thestop, subsectionstyle=show/show/hide] % removing hideothersubsections solves the problem
    \end{column}
    \hfill
    \begin{column}{.55\textwidth}
        \begin{centering}
            \insertsectionhead
        \end{centering}
    \end{column}
  \end{columns}
\end{frame}
}

\begin{document}
\begin{frame}[shrink]{ToC}
\tableofcontents
\end{frame}

\section[aa]{AA}
\begin{frame}{A}
a   
\end{frame}

\section[bb]{BB}
\begin{frame}{B}
b
\end{frame}

\section{CC}
\begin{frame}{C}
c
\end{frame}

\section{DD}
\begin{frame}{D}
d
\end{frame}

\section[ee]{EE}
\begin{frame}{E}
e
\end{frame}

\section[ff]{FF}
\begin{frame}{F}
f
\end{frame}

\section[gg]{GG}
\begin{frame}{G}
g
\end{frame}


\section[hh]{HH}
\begin{frame}{H}
h
\end{frame}


\section[ii]{II}
\subsection[iii]{III}
\subsection[iv]{IV}
\subsection[v]{V}
\begin{frame}{I}
i
\end{frame}
\end{document}
  • \ifnum\thesection>1 will fail if \thesection is not printing the integer number you expect. \ifnum1<\value{section} will not fail, however. You should never rely on \the.... printing the integer counter value – user31729 Jul 11 '17 at 20:46
  • @ChristianHupfer Thanks for the remark, I edited my answer :) – user36296 Jul 11 '17 at 20:50
  • Works like a charm! I used \tableofcontents[sections=\thestart-\thestop, currentsection, hideothersubsections, ] for transparency in other sections. – pushpen.paul Jul 12 '17 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.