在特殊条件下再次在 Beamer 中显示目录

在特殊条件下再次在 Beamer 中显示目录

我想知道如何显示目录:

  • 当且仅当 (A) 没有子节或 (B) 节中有框架时,才位于节的开头第一小节开始
  • 在所有小节的开头

这与问题非常相似在特殊条件下在 Beamer 中显示目录但答案没有显示条件 (B) 下的 TOC

\documentclass{beamer}
\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}
\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}
\usepackage{etoolbox}

\AtBeginSection[]
{
    \setcounter{totalsubsection}{\ObtainTrackedValueExp[\value{section}]{section}{subsection}}
    \ifnum\value{totalsubsection}=0%
      \begin{frame}
      \frametitle{Outline}
      \tableofcontents[currentsection]
      \end{frame}
    \fi%
}
\AtBeginSubsection[]
{
  \begin{frame}
  \tableofcontents[currentsection,currentsubsection]
  \end{frame}
}

\begin{document}

\section{Section1}

\subsection{Subsection1}
\frame{first content in section 1 is part of subsection 1 of section 1, therefore section 1 needs no separate introduction}


\section{Section2}
\frame{first content in section 2 comes before first subsection of section 2, therefore section 2 needs introduction at beginning (no one will know that this frame is already part of section 2)}

\subsection{Subsection1}
\frame{It's too late to introduce section 2 with this subsection}

\end{document}

在此处输入图片描述

相关内容