![自定义投影仪侧边栏,使其具有对齐的部分编号](https://linux22.com/image/317363/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8A%95%E5%BD%B1%E4%BB%AA%E4%BE%A7%E8%BE%B9%E6%A0%8F%EF%BC%8C%E4%BD%BF%E5%85%B6%E5%85%B7%E6%9C%89%E5%AF%B9%E9%BD%90%E7%9A%84%E9%83%A8%E5%88%86%E7%BC%96%E5%8F%B7.png)
我想知道如何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}
显示结果侧边栏的图像: