7

I want to add a ToC at the beginning of each section in my presentation without showing the frame in the navigation bar. I tried the following:

\AtBeginSection[]
{
  {
    \makeatletter
    \def\beamer@writeslidentry{\clearpage\beamer@notesactions}
    \makeatother
    \frame{
      \frametitle{Table of contents}
      \tableofcontents[
      currentsection,
      subsectionstyle=show/show/hide
      ]
    }
  }
}

This shows the frame correctly but does not hide it from the navigation bar. If I move the inner block to the beginning of each section manually, this works properly (see full code below).

How can I fix this?


I found the above on here but it was outside a AtBeginSection:


Full example:

\documentclass[usenames,dvipsnames,svgnames,table]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usetheme{Madrid}

\useoutertheme{miniframes}
\useinnertheme{circles}

% This one shows in the navigation bar -> Not good.
\AtBeginSection[]
{
  {
    \makeatletter
    \def\beamer@writeslidentry{\clearpage\beamer@notesactions}
    \makeatother
    \frame{
      \frametitle{Table of contents}
      \tableofcontents[
      currentsection,
      subsectionstyle=show/show/hide
      ]
    }
  }
}

\begin{document}

\section{Section 1}

% This one does not show in the navigation bar -> Ok.
{
  \makeatletter
  \def\beamer@writeslidentry{\clearpage\beamer@notesactions}
  \makeatother
  \frame{
    \frametitle{Table of contents}
    \tableofcontents[
    currentsection,
    subsectionstyle=show/show/hide
    ]
  }
}

\end{document}
Holt
  • 532
  • 1
  • 4
  • 14

2 Answers2

2

Very dirty hacks:

\documentclass{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usetheme{Madrid}
\useoutertheme{miniframes}

\makeatletter
\let\beamer@writeslidentry@miniframeson=\beamer@writeslidentry%
\def\beamer@writeslidentry@miniframesoff{%
  \expandafter\beamer@ifempty\expandafter{\beamer@framestartpage}{}% does not happen normally
  {%else
    % removed \addtocontents commands
    \clearpage\beamer@notesactions%
  }
}
\newcommand*{\miniframeson}{\let\beamer@writeslidentry=\beamer@writeslidentry@miniframeson}
\newcommand*{\miniframesoff}{\let\beamer@writeslidentry=\beamer@writeslidentry@miniframesoff}
\makeatother

\setbeamertemplate{section in head/foot}{\hspace*{1.7ex}\insertsectionhead}

\makeatletter
\setbeamertemplate{headline}{%
  \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
  \end{beamercolorbox}
  \begin{beamercolorbox}{section in head/foot}
    \vskip2pt\hspace*{-1.7ex}\insertnavigation{1.01\paperwidth}\vskip2pt
  \end{beamercolorbox}%
  \ifbeamer@theme@subsection%
    \begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
    \end{beamercolorbox}
    \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
      \usebeamerfont{subsection in head/foot}\insertsubsectionhead
    \end{beamercolorbox}%
  \fi%
  \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
  \end{beamercolorbox}
}
\makeatother

\AtBeginSection[]{%
    \miniframesoff
    \begin{frame}
      \frametitle{Table of contents}
      \tableofcontents[
      currentsection,
      subsectionstyle=show/show/hide
      ]
    \end{frame}
    \miniframeson
}



\begin{document}

\section{Section 1}

\begin{frame}

\end{frame}

\begin{frame}

\end{frame}

\section{Section 2}

\begin{frame}

\end{frame}

\end{document}
0

You can redefine \section to always execute the code for your table of contents after executing the old code of \section. Add the following to your preamble:

\makeatletter
\newcommand\mytableofcontents{%
   \begingroup
   \def\beamer@writeslidentry{\clearpage\beamer@notesactions}%
   \frame{%
      \frametitle{Table of contents}%
      \tableofcontents[%
        currentsection,
        subsectionstyle=show/show/hide
      ]%
   }%
   \endgroup
}
\let\orig@section\section
\renewcommand\section[1]{\orig@section{#1}\mytableofcontents}
\makeatother

If you decide do use also the optional argument of \section somewhere, you have to redefine \section accordingly to handle it as well.

gernot
  • 49,614