我有一个带有以下代码的 beamer 模板:
\begin{beamercolorbox}[wd=.24\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfill\hskip-17ex\insertsectionnavigation{.22\paperwidth}\vfill\hfill}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.24\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.18\paperwidth}\vfil}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.038\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\hspace*{0.6cm}\pgfuseimage{UT}\vfil}%
\end{beamercolorbox}%
这就是标题……我的问题是,导航的文本没有从左对齐开始。我希望文本一直位于框的左侧。文本总是从框的中间开始,并且有点向后输入。有人能帮我吗?
答案1
\insertsubsection
根据\insertsubsectionnavigation{⟨width⟩}
手册,你可能需要使用
插入一个垂直导航栏,其中包含当前部分的所有子部分,并突出显示当前子部分。
此栏在(子)部分的左侧和右侧添加了额外的空间。其工作方式与\insertsection
versus相同\insertsectionnavigation{⟨width⟩}
。
请与此示例进行比较:
\documentclass{beamer}
\makeatletter
\setbeamertemplate{headline}{%
\begin{beamercolorbox}[wd=.24\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfill\insertsection\vfill\hfill}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.24\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\insertsubsection\vfil}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.038\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\hspace*{0.6cm}\rule{2cm}{0.5cm}\vfil}%
\end{beamercolorbox}%
}
\makeatother
\begin{document}
\section{A section}
\subsection{A subsection}
\begin{frame}{A show frame}
just text here
\end{frame}
\end{document}
评论:
现在文本直接从框架边框开始,您可能想要插入一个\hspace*{1em}
。
我删除了\hskip-17ex
为了渲染其中的文本beamercolorbox
并使用规则代替了 UT 图像。
更新:
\insertsectionnavigation
或者,您可以重新定义和的模板\insertsubsectionnavigation
以beamerbasenavigation.sty
减少添加的水平空间和\RaggedRight
文本(使用ragged2e
包)。
\usepackage{ragged2e}
\makeatletter
\renewcommand\insertsectionnavigation[1]{%
\hbox to #1{%
\vbox{{\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
\vskip0.5ex%
\def\slideentry##1##2##3##4##5##6{}%
\def\sectionentry##1##2##3##4##5{%
\ifnum##5=\c@part%
\def\insertsectionhead{##2}%
\def\insertsectionheadnumber{##1}%
\def\insertpartheadnumber{##5}%
\setbox\beamer@tempbox=\hbox{\RaggedRight% added for flushed left text
\hyperlink{Navigation##3}{\hbox to #1{%
\hskip0.5ex% adjusted from 0.3 cm
\ifnum\c@section=##1%
{\usebeamertemplate{section in head/foot}}%
\else%
{\usebeamertemplate{section in head/foot shaded}}%
\fi\hskip0.5ex}}}% adjusted from 0.3 cm
\ht\beamer@tempbox=1.6875ex\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi}%
\dohead\vskip0.5ex}}\hfil}}
\renewcommand\insertsubsectionnavigation[1]{%
\hbox to #1{%
\vbox{{%
\usebeamerfont{subsection in head/foot}\usebeamercolor[fg]{subsection in head/foot}%
\vskip0.5625ex%
\beamer@currentsubsection=0%
\def\sectionentry##1##2##3##4##5{}%
\def\slideentry##1##2##3##4##5##6{\ifnum##6=\c@part\ifnum##1=\c@section%
\ifnum##2>\beamer@currentsubsection%
\beamer@currentsubsection=##2%
\def\insertsubsectionhead{##5}%
\def\insertsectionheadnumber{##1}%
\def\insertsubsectionheadnumber{##2}%
\def\insertpartheadnumber{##6}%
\setbox\beamer@tempbox=\hbox{\RaggedRight\beamer@link(##4){% added for flushed left text
\hbox to #1{\hskip0.5ex% adjusted from 0.3 cm
\ifnum\c@subsection=##2%
{\usebeamertemplate{subsection in head/foot}}%
\else%
{\usebeamertemplate{subsection in head/foot shaded}}%
\fi\hfil\hskip0.5ex}}}% adjusted from 0.3 cm
\ht\beamer@tempbox=1.6875ex\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi\fi\fi}%
\dohead\vskip0.5625ex}\hfil}}}
% headline template
\setbeamertemplate{headline}{%
\begin{beamercolorbox}[wd=.24\paperwidth]{section in head/foot}%
\insertsectionnavigation{.22\paperwidth}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.24\paperwidth]{section in head/foot}%
\insertsubsectionnavigation{.18\paperwidth}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.038\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\hspace*{0.6cm}\rule{2cm}{0.5cm}\vfil}%
\end{beamercolorbox}%
}
\makeatother