[Tex/LaTex] How to deactivate AtBeginSection for particular sections

beamersectioning

I have been using AtBeginSection to insert a title page at the beginning of a new section (following the answer to this question). The title page follows the format of the beamer theme. However, I want to deactivate this automatic title page or change the formatting for some specific sections. How can I do this?

Best Answer

You can use the optional argument of \AtBeginSection and \section* to insert a different code at the beginning of some sections. So you can use an empty optional argument for \AtBeginSection and \section* for the specific section without automatic title page.

\documentclass{beamer}
\usetheme{Madrid}

\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}

\title{The Title}
\author{The Author}
\institute{The Institute}

\begin{document}

\begin{frame}
\maketitle
\end{frame}

\section{Test section one}
\begin{frame}
test frame for section one
\end{frame}

\section*{Test section two}
\begin{frame}
test frame for section two
\end{frame}

\section{Test section three}
\begin{frame}
test frame for section three
\end{frame}

\end{document}

Result:

enter image description here


Update

If you can not use the starred version of \section because you need the bookmark, then maybe you can use \newif and define commands to switch for the next section or all following sections:

\documentclass{beamer}
\usetheme{Madrid}

\newif\ifSectionTitlePage
\newcommand*\SectionTitlePagedefault{\SectionTitlePagefalse}

\newcommand\AllSectionsWithTitlePage{%
  \SectionTitlePagetrue
  \renewcommand*\SectionTitlePagedefault{\SectionTitlePagetrue}%
}
\newcommand\AllSectionsWithoutTitlePage{%
  \SectionTitlePagefalse
  \renewcommand*\SectionTitlePagedefault{\SectionTitlePagefalse}%
}
\newcommand\NextSectionWithTitlePage{\SectionTitlePagetrue}
\newcommand\NextSectionWithoutTitlePage{\SectionTitlePagefalse}

\AtBeginSection[]{%
  \ifSectionTitlePage
    \begin{frame}
    \vfill
    \centering
    \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
      \usebeamerfont{title}\insertsectionhead\par%
    \end{beamercolorbox}
    \vfill
    \end{frame}
  \fi
  \SectionTitlePagedefault
}

\AllSectionsWithTitlePage% <- enable the title pages

\title{The Title}
\author{The Author}
\institute{The Institute}

\begin{document}

\begin{frame}
\maketitle
\end{frame}

\section{Test section one}
\begin{frame}
test frame for section one
\end{frame}

\NextSectionWithoutTitlePage% <- disable the title page for the next section
\section{Test section two}
\begin{frame}
test frame for section two
\end{frame}

\section{Test section three}
\begin{frame}
test frame for section three
\end{frame}
\end{document}

The result is the same as above but with a bookmark for section 2 too.