
Продолжая отэтот ответ от samcarter_is_at_topanswers.xyzв отношении вопроса section title in \frametitle beamer
я использовал предоставленный ответ:
\makeatletter
\patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{\insertsection-\insertframetitle}{}{}
\makeatother
в моем основном beamer
документе. Я изменил его так, чтобы вместо \insertsection
него было , \insertsubsection
так как мои подразделы более релевантны. Однако использование этого предсказуемо влияет на все мои frame
' независимо от того, \insertsubsection
является ли пустым (например, для страниц TOC). Мой основной документ в настоящее время выглядит так (я использовал \insertsection\ - \insertframetitle
вместо этого, обратите внимание на пробелы вокруг дефиса):
Как я могу проверить или включить только \patchcmd
эффект 's, когда присутствует подраздел (или с помощью любого метода/раздела, который работает)? Я также включаю TOC для каждого раздела, используя:
\AtBeginSection[]
{
\ifnum \value{framenumber}>1
\begin{frame}<beamer>
\frametitle{Outline}
\tableofcontents[currentsection]
\end{frame}
\else
\fi
}
и ссылки и, возможно, глоссарий в конце. Одно из возможных решений, которое я вижу, это просто перепатчить\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
}
МВЭ:
\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}
Выход МВЭ:
В идеале я хочу, чтобы заголовок подраздела находился в соответствующих рамках, но только если подраздел существует, а не в оглавлении/справочных/вводных слайдах и т. д. Если это невозможно, то я вернусь к отсутствию подразделов в , \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}