Beamer - \frametitle にサブセクションを含めますが、サブセクションが存在する場合のみ、つまり TOC、参照フレームなどを含めない場合のみです。

Beamer - \frametitle にサブセクションを含めますが、サブセクションが存在する場合のみ、つまり TOC、参照フレームなどを含めない場合のみです。

に続いてsamcarter_is_at_topanswers.xyz によるこの回答質問に関してはsection title in \frametitle beamer、提供された回答を使用しました:

\makeatletter
\patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{\insertsection-\insertframetitle}{}{}
\makeatother

メイン ドキュメントで を使用しています。サブセクションの関連性が高いため、のbeamer代わりに を使用するように変更しました。ただし、これを使用すると、が空であるかどうかに関係なく(目次ページなど)、すべての に影響が及ぶことは予想どおりです。メイン ドキュメントは現在次のようになっています (代わりに を使用しました。ハイフンの周りのスペースに注意してください)。\insertsection\insertsubsectionframe\insertsubsection\insertsection\ - \insertframetitle

ここに画像の説明を入力してください

サブセクションが存在する場合(または機能する任意の方法/区分を介して)の効果をテストしたり、その\patchcmd効果のみを含めたりするにはどうすればよいでしょうか。また、次を使用してセクションごとに目次を含めています。

\AtBeginSection[]
{
 \ifnum \value{framenumber}>1
  \begin{frame}<beamer>
   \frametitle{Outline}
   \tableofcontents[currentsection]
  \end{frame}
 \else
 \fi
}

最後に参考文献と用語集を追加するといいかもしれません。私が考える解決策の 1 つは、\beamer@@tmpl@frametitleタイトルにサブセクションを含めることを希望するスライドまたは含めたくないスライドの前後にコマンドを再パッチすることですが、おそらく私の知識を超えて、他の人が実行できるより良い方法があるかもしれません。そこで質問します。冗長な質問を避けるためにこれを試みましたが、次のように失敗しました。

ここに画像の説明を入力してください

使用:

\newcommand\showSubsec{
\makeatletter
\patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{\insertsubsection\ - \insertframetitle}{}{}
\makeatother
}

\newcommand\hideSubsec{
\makeatletter
\patchcmd\beamer@@tmpl@frametitle{\insertsubsection\ - \insertframetitle}{\insertframetitle}{}{}
\makeatother
}

MWE:

\documentclass{beamer}

\usepackage{xpatch}
\makeatletter
\patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{\insertsubsection\ - \insertframetitle}{}{}
\makeatother

% For TOC at each section
\AtBeginSection[]
{
 \ifnum \value{framenumber}>1
  \begin{frame}<beamer>
   \frametitle{Outline}
   \tableofcontents[currentsection]
  \end{frame}
 \else
 \fi
}

\begin{document}

\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}

\begin{frame}
\frametitle{Introduction}
Introduction
\end{frame}

\section{First section}
\subsection{First subsection}
\begin{frame}
    \frametitle{First slide Title}
    Text
\end{frame}

\subsection{Second subsection}
\begin{frame}
    \frametitle{Second slide Title}
    \small
    Text
\end{frame}

\section{Conclusions and Future Work}
\subsection{Conclusions}
\begin{frame}
    \frametitle{Conclusions}
    \centering
    Text
\end{frame}

\subsection{Future Work}
\begin{frame}
    \frametitle{Future Work}
    \centering
    Text
\end{frame}

\section*{Back matter}
\subsection*{References}
\begin{frame}
\frametitle{References}
References
\end{frame}

\end{document}

MWE出力:

ここに画像の説明を入力してください

理想的には、サブセクションのタイトルを関連するフレームに表示したいのですが、サブセクションが存在する場合にのみ表示し、目次/参照/紹介スライドなどには表示しません。これが不可能な場合は、サブセクションを非表示に戻しますが、\frametitle可能であればお願いします。

答え1

たとえば、サブセクション カウンターが 0 より大きいかどうかをテストできます。

\documentclass{beamer}

\usepackage{xpatch}
\makeatletter
\patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{%
\ifnum\thesubsection>0
  \insertsubsection\ - 
\fi
\insertframetitle
}{}{}
\makeatother

% For TOC at each section
\AtBeginSection[]
{
 \ifnum \value{framenumber}>1
  \begin{frame}<beamer>
   \frametitle{Outline}
   \tableofcontents[currentsection]
  \end{frame}
 \else
 \fi
}

\begin{document}

\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}

\begin{frame}
\frametitle{Introduction}
Introduction
\end{frame}

\section{First section}
\subsection{First subsection}
\begin{frame}
    \frametitle{First slide Title}
    Text
\end{frame}

\subsection{Second subsection}
\begin{frame}
    \frametitle{Second slide Title}
    \small
    Text
\end{frame}

\section{Conclusions and Future Work}
\subsection{Conclusions}
\begin{frame}
    \frametitle{Conclusions}
    \centering
    Text
\end{frame}

\subsection{Future Work}
\begin{frame}
    \frametitle{Future Work}
    \centering
    Text
\end{frame}

\section*{Back matter}
\subsection*{References}
\begin{frame}
\frametitle{References}
References
\end{frame}

\end{document}

関連情報