我想用 Beamer 创建一个演示文稿,其标题与主题 CambridgeUS 的标题类似,即它包含当前部分(左)和子部分(右)的名称,但我想添加当前部分和子部分的编号。我该如何实现?
答案1
您可以像这样重新定义标题:
\documentclass{beamer}
\usetheme{CambridgeUS}
\makeatletter
\setbeamertemplate{headline}
{%
\leavevmode%
\hbox{%
\usebeamerfont{section in head/foot}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,right]{section in head/foot}%
\usebeamerfont{headline}%
\usebeamerfont{section in head/foot}%
\ifnum\insertsectionnumber>0
\insertsectionnumber~
\fi
\insertsectionhead
\hspace*{2ex}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,left]{subsection in head/foot}%
\usebeamerfont{headline}%
\usebeamerfont{subsection in head/foot}%
\hspace*{2ex}%
\ifnum\insertsubsectionnumber>0
\insertsubsectionnumber~
\fi
\insertsubsectionhead
\end{beamercolorbox}}%
\vskip0pt%
}
\makeatother
\begin{document}
\begin{frame}
content...
\end{frame}
\section{title}
\subsection{title}
\begin{frame}
abc
\end{frame}
\section{title}
\begin{frame}
abc
\end{frame}
\end{document}