我在 Beamer 中做演示,使用华沙主题。我大约有 5-6 个部分,它们都在每个页面的顶部提及。这使得可用的框架空间更小。我可以将此数字限制为 3 吗?例如,显示上一节、当前节和下一节。
梅威瑟:
\documentclass{beamer}
\mode<presentation>
{
\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
\usetheme{Warsaw}
\usefonttheme[onlysmall]{structurebold}
}
\begin{document}
\section{Test 1}
\begin{frame} \end{frame}
\section{Test 2}
\begin{frame} \end{frame}
\section{Test 3}
\begin{frame} \end{frame}
\section{Test 4}
\begin{frame} \end{frame}
\section{Test 5}
\begin{frame} \end{frame}
\end{document}
答案1
版本 1
您好,您可以改变插入导航列表的宏。
\documentclass{beamer}
\makeatletter
\def\insertsectionnavigation#1{%
\hbox to #1{%
\vbox{{\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
\vskip0.5625ex%
\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{%
\hyperlink{Navigation##3}{\hbox to #1{%
\hskip0.3cm%
\ifnum\c@section=##1%
{\usebeamertemplate{section in head/foot}}%
\else%
{%
\advance\c@section by -1 %
\ifnum##1 = \c@section%
\usebeamertemplate{section in head/foot shaded}%
\else%
\advance\c@section by 2 %
\ifnum##1 = \c@section%
\usebeamertemplate{section in head/foot shaded}%
\else
\fi
\fi
}%
\fi\hskip0.3cm}}}%
\ht\beamer@tempbox=1.6875ex\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi}%
\dohead\vskip0.5625ex}}\hfil}}
\makeatother
\usetheme{Warsaw}
\usefonttheme[onlysmall]{structurebold}
\begin{document}
\section{Test 1}
\begin{frame} \end{frame}
\section{Test 2}
\begin{frame} \end{frame}
\section{Test 3}
\begin{frame} \end{frame}
\section{Test 4}
\begin{frame} \end{frame}
\section{Test 5}
\begin{frame} \end{frame}
\end{document}
Here two new conditionals are introduced, which check for the distance between the active section (stored in `\c@section`) and the printed sections.
The result is this:
![enter image description here][1]
版本 2
此版本更适合三行的大小。请注意,彩色投影框的高度是手动调整的。
\documentclass{beamer}
\usetheme{Warsaw}
\usefonttheme[onlysmall]{structurebold}
\makeatletter
\newcount\c@p
\newcount\c@m
\def\insertsectionnavigation#1{%
\hbox to #1{%
\vbox{{\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
\vskip0.5625ex%
\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}%
\c@p=\c@section%
\c@m=\c@section%
\advance\c@m by -1 %
\advance\c@p by 1 %
\ifnum\c@section=##1%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot}\hskip0.3cm}}}}%
\else%
\ifnum##1=\c@m%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm}}}}
%
\else%
\ifnum##1=\c@p%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm}}}}%
%
\else%
%
\fi%
\fi%
%
\fi%%
%
\ht\beamer@tempbox=1.6875ex%
\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi}%
\dohead\vskip0.5625ex}}\hfil}}
\setbeamertemplate{headline}%{split theme} % full manual adjustment
{%
\leavevmode%
\@tempdimb=3em%
\ifdim\@tempdimb>0pt%
\advance\@tempdimb by 1.825ex%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\insertsectionnavigation{.5\paperwidth}\vfil}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
\vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.5\paperwidth}\vfil}%
\end{beamercolorbox}%
\fi%
}
\makeatother
\begin{document}
\section{Test 1}
\begin{frame} \end{frame}
\section{Test 2}
\begin{frame} \end{frame}
\section{Test 3}
\begin{frame} \end{frame}
\section{Test 4}
\begin{frame} \end{frame}
\section{Test 5}
\begin{frame} \end{frame}
\end{document}
再次,if 结构选择所需的条目。但在这种情况下,框仅在需要时才填充。我还引入了两个辅助变量c@p
,c@m
以避免过于复杂的分组。这呈现为:
下面的框架将如下所示:
版本 3
现在可随时提供三种导航元素:
\documentclass{beamer}
\usetheme{Warsaw}
\usefonttheme[onlysmall]{structurebold}
\makeatletter
\newcount\c@p
\newcount\c@m
\newcount\c@pp
\newcount\c@mm
\def\insertsectionnavigation#1{%
\hbox to #1{%
\vbox{{\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
\vskip0.5625ex%
\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}%
\c@p=\c@section%
\c@m=\c@section%
\c@pp=\c@section%
\c@mm=\c@section%
\advance\c@m by -1 %
\advance\c@p by 1 %
\advance\c@mm by -2 %
\advance\c@pp by 2 %
%
\ifnum \c@section=1
\ifnum\c@section=##1%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot}\hskip0.3cm}}}}%
\else%
\ifnum##1=\c@p%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm}}}}
%
\else%
\ifnum##1=\c@pp%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm}}}}%
%
\else%
%
\fi%
\fi%
%
\fi%%
\else%
\ifnum \c@section=\beamer@sectionmax
\ifnum\c@section=##1%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot}\hskip0.3cm}}}}%
\else%
\ifnum##1=\c@m%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm}}}}
%
\else%
\ifnum##1=\c@mm%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm}}}}%
%
\else%
%
\fi%
\fi%
%
\fi%%
\else%
\ifnum\c@section=##1%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot}\hskip0.3cm}}}}%
\else%
\ifnum##1=\c@m%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm}}}}
%
\else%
\ifnum##1=\c@p%
\setbox\beamer@tempbox=\hbox{%
\hyperlink{Navigation##3}{\hbox to #1{%
{\hskip0.3cm\usebeamertemplate{section in head/foot shaded}\hskip0.3cm}}}}%
%
\else%
%
\fi%
\fi%
%
\fi%%
%
\fi
\fi
%
\ht\beamer@tempbox=1.6875ex%
\dp\beamer@tempbox=0.75ex%
\box\beamer@tempbox\fi}%
\dohead\vskip0.5625ex}}\hfil}}
\setbeamertemplate{headline}%{split theme} % full manual adjustment
{%
\leavevmode%
\@tempdimb=3em%
\ifdim\@tempdimb>0pt%
\advance\@tempdimb by 1.825ex%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{section in head/foot}%
\vbox to\@tempdimb{\vfil\insertsectionnavigation{.5\paperwidth}\vfil}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=\@tempdimb]{subsection in head/foot}%
\vbox to\@tempdimb{\vfil\insertsubsectionnavigation{.5\paperwidth}\vfil}%
\end{beamercolorbox}%
\fi%
}
\makeatother
\begin{document}
\section{Test 1}
\begin{frame} \end{frame}
\section{Test 2}
\begin{frame} \end{frame}
\section{Test 3}
\begin{frame} \end{frame}
\section{Test 4}
\begin{frame} \end{frame}
\section{Test 5}
\begin{frame} \end{frame}
\end{document}
需要说明的是,这是硬编码的。这仅适用于 3 个元素,而且用途不大。它的作用很简单:检查当前帧是第一帧还是最后一帧,并据此插入导航。
我想补充一点,这种导航方式对读者很不友好。读者必须非常仔细地观察才能理解。
第一张幻灯片如下所示: