希望提供使用beamer接口的方法。
\documentclass{beamer}
\setbeamertemplate{section in toc}[sections numbered]
\begin{document}
\frame{
\contentsname
\tableofcontents
}
\section{sectionone}
\frame{\frametitle{sectionone}some text}
\section{sectiontwo}
\frame{\frametitle{sectiontwo}some text}
\end{document}
默认的格式不满足你的需求,那么你可以自定义, 修改下面这行内容就行了:
\kern10ex\inserttocsection\par}
比如我这里修改成了 10ex
, 可自行修改为你喜欢的宽度. 完整代码如下:
\documentclass{beamer}
\setbeamertemplate{section in toc}{%
\leavevmode\leftskip=1.75ex%
\llap{%
\hbox to 2.25ex{\hfil\inserttocsectionnumber.\hfil}}%
\kern10ex\inserttocsection\par}
\begin{document}
\frame{
\contentsname
\tableofcontents
}
\section{sectionone}
\frame{\frametitle{sectionone}some text}
\section{sectiontwo}
\frame{\frametitle{sectiontwo}some text}
\end{document}
你也可以写得再规范一点, 就像下面这样:
\documentclass{beamer}
\defbeamertemplate{section in toc}{Your style}{%
\leavevmode\leftskip=1.75ex%
\llap{%
\hbox to 2.25ex{\hfil\inserttocsectionnumber.\hfil}}%
\kern10ex\inserttocsection\par}
\setbeamertemplate{section in toc}[Your style]
\begin{document}
\frame{
\contentsname
\tableofcontents
}
\section{sectionone}
\frame{\frametitle{sectionone}some text}
\section{sectiontwo}
\frame{\frametitle{sectiontwo}some text}
\end{document}
二者的效果是一致的, 编译结果如下: