我正在尝试将“第 1 节”和“第 1 小节”替换为节和小节名称前的相应数字。即:“1 这是第一节”和“1.1 这是第一小节”。基本上,我想使用与普通 LaTeX 文档相同的编号程序,但我不知道如何实现这一点。
\documentclass[xcolor=dvipsnames]{beamer}
\usetheme{Frankfurt}
\usecolortheme{crane}
\usefonttheme{default}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\title{Some title}
\author{Someone}
\date{today}
\begin{document}
\maketitle
\begin{frame}
\section{This is the first section}
\sectionpage
\subsection{This is the first subsection}
\subsectionpage
\end{frame}
\end{document}
答案1
(请注意,诸如等分段命令\section
应\subsection
始终位于框架环境之外)
您可以像这样重新定义章节和子章节页面的模板:
\documentclass[xcolor=dvipsnames]{beamer}
\usetheme{Frankfurt}
\usecolortheme{crane}
\usefonttheme{default}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
\title{Some title}
\author{Someone}
\date{today}
\makeatletter
\setbeamertemplate{section page}
{
\begingroup
\centering
% {\usebeamerfont{section name}\usebeamercolor[fg]{section name}\sectionname~\insertsectionnumber}
\vskip1em\par
\begin{beamercolorbox}[sep=12pt,center,colsep=-4bp,rounded=true,shadow=true]{section title}
\usebeamerfont{section title}\insertsectionnumber~\insertsection\par
\end{beamercolorbox}
\endgroup
}
\setbeamertemplate{subsection page}
{
\begingroup
\centering
% {\usebeamerfont{subsection name}\usebeamercolor[fg]{subsection name}\subsectionname~\insertsubsectionnumber}
\vskip1em\par
\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp,rounded=true,shadow=true]{subsection title}
\usebeamerfont{subsection title}\insertsubsectionnumber~\insertsubsection\par
\end{beamercolorbox}
\endgroup
}
\makeatother
\begin{document}
\maketitle
\section{This is the first section}
\subsection{This is the first subsection}
\begin{frame}
\sectionpage
\subsectionpage
\end{frame}
\end{document}