我一直在用 Beamer 制作幻灯片演示。感谢这个问题我有以下代码,它生成带有标题的幻灯片,标题中包含章节和子章节
\documentclass[10pt]{beamer}
\graphicspath{{./Figures/}}
\usetheme[progressbar=frametitle]{metropolis}
\setbeamercolor{progress bar}{fg=orange,bg=green}
\makeatletter
\setbeamertemplate{headline}
{%
{\usebeamerfont{section in head/foot}
\begin{beamercolorbox}[ht=3.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{section in head/foot}
\usebeamercolor[fg]{section in head/foot}%
\insertsectionhead
\end{beamercolorbox}}%
\begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
\end{beamercolorbox}
{\usebeamerfont{subsection in head/foot}
\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
\insertsubsectionhead
\end{beamercolorbox}}%
\begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
\end{beamercolorbox}
}
\makeatother
\setbeamercolor{section in head/foot}{fg=normal text.bg, bg=structure.fg}
\setbeamerfont{section in head/foot}{size=\small}
\setbeamerfont{subsection in head/foot}{size=\small}
\begin{document}
\section{Introduction}
\subsection{Subsection}
\begin{frame}{Introduction}
\begin{center}
I have text here
\end{center}
\end{frame}
\end{document}
现在,我想知道是否存在一种方法来包含子部分,但只在一张幻灯片中,例如,在单张幻灯片的标题中添加另一行,然后手动引入子部分的名称,例如
而其他幻灯片一开始就只有Section
和。Subsection
答案1
使用最新版本的 beamer(v3.70 或更新版本),您可以暂时在标题中添加另一个框,如下所示:
\documentclass[10pt]{beamer}
\graphicspath{{./Figures/}}
\usetheme[progressbar=frametitle]{moloch}% modern fork of the metropolis theme
\setbeamercolor{progress bar}{fg=orange,bg=green}
\makeatletter
\setbeamertemplate{headline}
{%
{\usebeamerfont{section in head/foot}
\begin{beamercolorbox}[ht=3.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{section in head/foot}
\usebeamercolor[fg]{section in head/foot}%
\insertsectionhead
\end{beamercolorbox}}%
\begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
\end{beamercolorbox}
{\usebeamerfont{subsection in head/foot}
\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
\insertsubsectionhead
\end{beamercolorbox}}%
\begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
\end{beamercolorbox}
}
\makeatother
\setbeamercolor{section in head/foot}{fg=normal text.bg, bg=structure.fg}
\setbeamercolor{subsubsection in head/foot}{fg=normal text.bg, bg=structure.fg}
\setbeamerfont{section in head/foot}{size=\small}
\setbeamerfont{subsection in head/foot}{size=\small}
\setbeamerfont{subsubsection in head/foot}{size=\small}
\begin{document}
\section{Introduction}
\subsection{Subsection}
\subsubsection{Subsubsection}
\begingroup
\addtobeamertemplate{headline}{}{
{\usebeamerfont{subsubsection in head/foot}
\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsubsection in head/foot}
\insertsubsubsectionhead
\end{beamercolorbox}}%
}
\begin{frame}{Introduction}
\begin{center}
I have text here
\end{center}
\end{frame}
\endgroup
\begin{frame}
content...
\end{frame}
\end{document}