Beamer 目录自定义项目符号:长节标题不对齐

Beamer 目录自定义项目符号:长节标题不对齐

我已将幻灯片中的目录项目符号重新定义为带圆圈的数字。但是,跨越多行的长节标题不与上一行的文本对齐,而是与节编号对齐。我该如何修复此问题?

最小工作示例

\documentclass{beamer}

\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=1pt] (char) {#1};}}

\setbeamertemplate{section in toc}{
    \protect\usebeamercolor[fg]{enumerate item}%
    \protect\circled{\inserttocsectionnumber}~\inserttocsection%
}

\begin{document}

\section{some really long title some really long title some really long title
         some really long title}

\begin{frame}{Contents}
    \tableofcontents[currentsection,hideallsubsections,subsubsectionstyle=hide]
\end{frame}

\end{document}

答案1

以下答案基于

beamerbaseauxtemplates.sty

只是稍微改变了一下颜色和线条样式

\documentclass{beamer}

\setbeamertemplate{section in toc}{
    \leavevmode\leftskip=2ex%
    \llap{%
        \usebeamerfont*{section number projected}%
        \usebeamercolor{section number projected}%
        \begin{pgfpicture}{-1ex}{0ex}{1ex}{2ex}
            \color{bg}
            \pgfpathcircle{\pgfpoint{0pt}{.75ex}}{1.4ex}
            \pgfusepath{stroke}
            \pgftext[base]{\color{bg}\inserttocsectionnumber}
        \end{pgfpicture}\kern1.25ex%
    }%
    \inserttocsection\par
}

\begin{document}

    \section{some really long title some really long title some really long title
        some really long title}

    \begin{frame}{Contents}
        \tableofcontents[currentsection,hideallsubsections,subsubsectionstyle=hide]
    \end{frame}

\end{document}

在此处输入图片描述

答案2

\documentclass{beamer}

\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=1pt] (char) {#1};}}

\setbeamertemplate{section in toc}{%
    \usebeamercolor[fg]{enumerate item}%
    \makebox[2em][l]{\circled{\inserttocsectionnumber}}%
    \parbox[t]{\dimexpr\linewidth-2em}{\inserttocsection}%
}

\begin{document}

\section{some really long title some really long title some really long title
         some really long title}

\begin{frame}{Contents}
    blblblbl % to show the margin
    \tableofcontents[currentsection,hideallsubsections,subsubsectionstyle=hide]
\end{frame}

\end{document}

相关内容