beamer中目录条目`1. sectionone`中的`1.`和`s`之间的水平间距如何调整?

发布于 2025-08-23 04:16:27

希望提供使用beamer接口的方法。
image.png

\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}

查看更多

关注者
0
被浏览
65
1 个回答
Eureka
Eureka 5小时前
这家伙很懒,什么也没写!

默认的格式不满足你的需求,那么你可以自定义, 修改下面这行内容就行了:

\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}

二者的效果是一致的, 编译结果如下:
image.png

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览