[Tex/LaTex] beamer table of content: put only the current section and subsection at the top of the slide

beamertable of contentsvertical alignment

I'm writing a rather long beamer, with many sections. The toc with sections fit in a single slide, but when, at each section, I show the subsections, it gets too long and we cannot see it. I would like , at each beginning of section/subsection, to display the toc for that section only, aligned at the top.

Currently, when getting to section 4, I get, where === represents the slide limit:

 ============

1. Section1
2. Section2
3. Section3
4. Section4

  4.1 Subsection 41

===================

  4.2 Subsection 42 (so it gets out of the slide)

5. Section5

I want to have:

==========

4. Section4 (aligned at the top of the slide !)

  4.1 Subsection 41

  4.2 Subsection 42 

(free space here)

========

Even if i use sectionstyle=show/hide, subsectionstyle=show/shaded/hide, the position of the section is "remembered".

Thanks!

Best Answer

To only display the ToC of the current section, you can use

\documentclass{beamer}

\AtBeginSection{%
    \begin{frame}
        \tableofcontents[sections=\value{section}]
    \end{frame}
}

\begin{document}

\section{sec1}
\subsection{sub1}
\frame{abc}

\section{sec2}
\subsection{sub2}
\frame{abc} 

\end{document}