![如何在默认投影仪模板的标题中添加该部分?](https://linux22.com/image/314799/%E5%A6%82%E4%BD%95%E5%9C%A8%E9%BB%98%E8%AE%A4%E6%8A%95%E5%BD%B1%E4%BB%AA%E6%A8%A1%E6%9D%BF%E7%9A%84%E6%A0%87%E9%A2%98%E4%B8%AD%E6%B7%BB%E5%8A%A0%E8%AF%A5%E9%83%A8%E5%88%86%EF%BC%9F.png)
默认的 beamer 模板只在标题中显示子部分。我希望它既显示部分,又显示子部分。可以通过将主题更改为信息行等来实现,但我更喜欢使用默认主题,只需在标题中添加部分名称即可。
原始框架如下所示:
以下是我想要的:
梅威瑟:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
%Modify theme
\setbeamertemplate{navigation symbols}{} %get rid of navigation symbols
\setbeamertemplate{sections/subsections in toc}[ball unnumbered] %bullets in table of contents should be balls
\setbeamertemplate{itemize items}[ball] %bullets in frames should be balls
\title{My title}
\author{My name}
\institute{My institute}
\date{\today}
\begin{document}
\maketitle
\begin{frame}{Outline}
\tableofcontents
\end{frame}
\section{Section 1}
\begin{frame}{Section 1}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}
\section{Section 2}
\subsection{Subsection 2.1}
\begin{frame}{Subsection 2.1}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}
\subsection{Subsection 2.2}
\begin{frame}{Subsection 2.2}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}
\end{document}
答案1
一种可能性是(重新)定义一个适当的模板(合理的候选者是headline
或frame title
)来使用\insertsectionhead
和\insertsubsectionhead
:
代码:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
%Modify theme
\setbeamertemplate{navigation symbols}{} %get rid of navigation symbols
\setbeamertemplate{sections/subsections in toc}[ball unnumbered] %bullets in table of contents should be balls
\setbeamertemplate{itemize items}[ball] %bullets in frames should be balls
\setbeamertemplate{headline}{%
\leavevmode%
\begin{beamercolorbox}[sep=0.3cm,wd=\paperwidth]{section in head/foot}%
\usebeamercolor[fg]{structure}\Large\insertsectionhead\hfill\insertsubsectionhead%
\end{beamercolorbox}%
}
\title{My title}
\author{My name}
\institute{My institute}
\date{\today}
\begin{document}
\maketitle
\begin{frame}{Outline}
\tableofcontents
\end{frame}
\section{Section 1}
\begin{frame}
\frametitle{Title for the frame}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}
\section{Section 2}
\subsection{Subsection 2.1}
\begin{frame}
\frametitle{Title for the frame}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}
\subsection{Subsection 2.2}
\begin{frame}
\frametitle{Title for the frame}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{frame}
\end{document}