如何自定义 Beamer 编号?

如何自定义 Beamer 编号?

我想按以下顺序对我的部分进行编号:

  • 各部分的罗马数字(I、II、III......)
  • 子部分用阿拉伯数字表示(1、2、3...)。我该如何加点?这是我的 MWE:
\documentclass{beamer}

\begin{document}

\frame{\titlepage}

\begin{frame}{Outline}

\tableofcontents    

\end{frame}    

\section{A title}

\begin{frame}

\end{frame}

\subsection{Another title}

\begin{frame}

\end{frame}

\end{document}

答案1

\documentclass{beamer}

\makeatletter

\setbeamertemplate{section in toc}{%
  \leavevmode%
  % prevents the period to be printed with the first/last section option
  \ifnum\beamer@tempcount>\beamer@toclastsection
  \else
  \ifnum\beamer@tempcount>0
    \@Roman\inserttocsectionnumber~
  \fi\fi%
  \inserttocsection\par%
}

\setbeamertemplate{subsection in toc}{\leavevmode\leftskip=2em\rlap{\hskip-2em\@Roman\inserttocsectionnumber.\inserttocsubsectionnumber}\inserttocsubsection\par}

\makeatother

\begin{document}

\frame{\titlepage}

\begin{frame}{Outline}

\tableofcontents    

\end{frame}    

\section{A title}

\begin{frame}

\end{frame}

\subsection{Another title}

\begin{frame}

\end{frame}

\end{document}

在此处输入图片描述

答案2

基于一个旧 @samcarter_is_at_topanswers.xyz 回答答案。只是 ToC 样式有点不同:

在此处输入图片描述

\documentclass{beamer}
\makeatletter
\defbeamertemplate{section in toc}{sections numbered roman}{%
    \makebox[2em]{\hfill\@Roman\inserttocsectionnumber.}\space%
    \inserttocsection\par
}
\defbeamertemplate{subsection in toc}{sections numbered arabic}{%
    \makebox[3em]{\hfill\@arabic\inserttocsubsectionnumber.}\space%
    \inserttocsubsection\par
}
\makeatother
\setbeamertemplate{section in toc}[sections numbered roman]
\setbeamertemplate{subsection in toc}[sections numbered arabic]


\begin{document}
\frame{\titlepage}

\begin{frame}{Outline}
    \tableofcontents
\end{frame}

\section{First section title}
\section{Second section title}
\section{Third section title}

\begin{frame}
    aaaa
\end{frame}

\subsection{First subsection title}
\subsection{Second subsection title}

\begin{frame}
    bbbb
\end{frame}

\end{document}

相关内容