我想知道如何beamer
编辑侧边栏中的垂直导航,以便让章节编号像目录中那样左对齐。
这个问题非常类似于这个我认为 MWE 也可以使用。
为了更清楚地说明我想要实现的目标,我上传了一张已实现对齐的 beamer 主题(非公开)的图片:
如您所见,节号固定在节标题的左侧,子节的起始位置与节完全相同。换行符也从该 x 位置开始。其他文本(如标题)也固定在此位置。
提前致谢!
答案1
\parbox
您可以对数字和标题使用并排的 es 来实现这一点;更改\secinsidebarindent
(dafault = 10pt
)以控制为数字保留的框的宽度:
\documentclass{beamer}
\usetheme{Marburg}
\newlength\secinsidebarindent
\setlength\secinsidebarindent{10pt}
\makeatletter
\setbeamertemplate{sidebar \beamer@sidebarside}
{
\beamer@tempdim=\beamer@sidebarwidth%
\advance\beamer@tempdim by -6pt%
\vskip4em%
\insertverticalnavigation{\beamer@sidebarwidth}%
\vfill
\ifx\beamer@sidebarside\beamer@lefttext%
\else%
\usebeamercolor{normal text}%
\llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}%
\vskip2pt%
\fi%
}%
\ifx\beamer@sidebarside\beamer@lefttext%
\defbeamertemplate*{sidebar right}{sidebar theme}
{%
\vfill%
\llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}%
\vskip2pt}
\fi
\setbeamertemplate{section in sidebar}%{sidebar theme}
{%
\vbox{%
\vskip1ex%
\beamer@sidebarformat{3pt}{section in sidebar}{%
\parbox[t]{\secinsidebarindent}{\insertsectionheadnumber\hfill}%
\parbox[t]{\dimexpr\beamer@sidebarwidth-\secinsidebarindent-6pt\relax}{\raggedright\insertsectionhead}}%
}%
}
\setbeamertemplate{section in sidebar shaded}%{sidebar theme}
{%
\vbox{%
\vskip1ex%
\beamer@sidebarformat{3pt}{section in sidebar shaded}{%
\parbox[t]{\secinsidebarindent}{\insertsectionheadnumber\hfill}%
\parbox[t]{\dimexpr\beamer@sidebarwidth-\secinsidebarindent-6pt\relax}{\raggedright\insertsectionhead}}%
}%
}
\setbeamertemplate{subsection in sidebar}%{sidebar theme}
{%
\vbox{%
\vskip2ex%
\beamer@sidebarformat{3pt}{subsection in sidebar}{%
\parbox[t]{\secinsidebarindent}{\hfill}%
\parbox[t]{\dimexpr\beamer@sidebarwidth-\secinsidebarindent-6pt\relax}{\raggedright\insertsubsectionhead}}%
}%
}
\setbeamertemplate{subsection in sidebar shaded}%{sidebar theme}
{%
\vbox{%
\vskip2ex%
\beamer@sidebarformat{3pt}{subsection in sidebar shaded}{%
\parbox[t]{\secinsidebarindent}{\hfill}%
\parbox[t]{\dimexpr\beamer@sidebarwidth-\secinsidebarindent-6pt\relax}{\raggedright\insertsubsectionhead}}%
}%
}
\makeatother
\begin{document}
\section{First test section with a long title}
\begin{frame} test \end{frame}
\subsection{A test subsection}
\begin{frame} test \end{frame}
\section{Second test section with another long title}
\begin{frame} test \end{frame}
\subsection{A test subsection}
\begin{frame} test \end{frame}
\section{Yet another section}
\begin{frame} test \end{frame}
\subsection{A test subsection}
\begin{frame} test \end{frame}
\end{document}
显示结果侧边栏的图像: