我喜欢它提供的直观导航smoothbars
。但是,当演示文稿包含太多部分时,很难很好地显示它。在这种情况下,我希望有一个像 这样的拆分标题infolines
。
因此,我怎样才能兼得两全其美的优势,既拥有 的导航smoothbars
,又拥有 的拆分标题infolines
,就像这样:
我的版块在左边,导航在右边。我搜索了一下,但没有任何结果。
\documentclass{beamer}
\usetheme{Warsaw}
\useoutertheme[subsection=false]{smoothbars}
%\useoutertheme{infolines}
\begin{document}
\section{Test}
\subsection{test1}
\frame{one}
\subsection{test1}
\frame{one}
\section{Test 2}
\subsection{test1}
\frame{one}
\frame{two}
\subsection{test1}
\frame{one}
\section{Test 3}
\subsection{test1}
\frame{one}
\frame{three}
\subsection{test1}
\frame{one}
\end{document}
答案1
您可以定义自己的导航栏,仅显示当前部分的迷你框架以供模板使用headline
:
\documentclass{beamer}
\usetheme{Warsaw}
\useoutertheme[subsection=false]{smoothbars}
% Smoothbars meets infolines
% (http://tex.stackexchange.com/a/112571)
\makeatletter
\def\insertminiframescurrentsection{%
\def\sectionentry##1##2##3##4##5{}
\def\slideentry##1##2##3##4##5##6{%
%section number, subsection number, slide number, first/last frame, page number, part number
\ifnum##6=\c@part\ifnum##1=\c@section\ifnum##2>0\ifnum##3>0%
\advance\beamer@xpos by1\relax%
\hbox to 0pt{%
\beamer@tempdim=-\beamer@vboxoffset%
\advance\beamer@tempdim by-\beamer@boxsize%
\multiply\beamer@tempdim by\beamer@ypos%
\raise\beamer@tempdim\hbox{%
\beamer@tempdim=\beamer@boxsize%
\multiply\beamer@tempdim by\beamer@xpos%
\advance\beamer@tempdim by -\beamer@boxsize%
\advance\beamer@tempdim by 1pt%
\kern\beamer@tempdim
\global\beamer@section@min@dim\beamer@tempdim
\hbox{\beamer@link(##4){%
\usebeamerfont{mini frame}%
\ifnum\c@section=##1%
\ifnum\c@subsection=##2%
\usebeamercolor[fg]{mini frame}%
\ifnum\c@subsectionslide=##3%
\usebeamertemplate{mini frame}%\beamer@minislidehilight%
\else%
\usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
\fi%
\else%
\usebeamercolor{mini frame}%
%\color{fg!50!bg}%
\usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
\fi%
\else%
\usebeamercolor{mini frame}%
%\color{fg!50!bg}%
\usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
\fi%
}}}\hskip-10cm plus 1fil%
}\fi\fi\fi%
\ignorespaces
}
\vbox{{%
\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
\beamer@xpos=0\relax%
\beamer@ypos=0\relax%
\hbox{\setbox\beamer@sectionbox=\hbox{\kern1sp}%
\ht\beamer@sectionbox=1.875ex%
\dp\beamer@sectionbox=0.75ex%
\hskip-1.875ex plus-1fill%
\global\beamer@section@min@dim\z@
\dohead%
\beamer@section@set@min@width
\box\beamer@sectionbox\hfil\hskip.3cm}%
}}}
\AtBeginDocument
{
\usebeamerfont*{headline}
\colorlet{global.bg}{bg}
\usebeamercolor{subsection in head/foot}
\usebeamercolor{section in head/foot}
\usebeamercolor{frametitle}
\pgfdeclareverticalshading{beamer@barshade}{\the\paperwidth}{%
color(0ex)=(global.bg);%
color(1ex)=(section in head/foot.bg);%
color(5ex)=(section in head/foot.bg)%
}
}
\setbeamertemplate{headline}
{
\pgfuseshading{beamer@barshade}\vskip-5ex% Remove this line if you don't want a shadow below the headline
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,right]{section in head/foot}%
\usebeamerfont{section in head/foot}\insertsectionhead\hspace*{2ex}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,left]{subsection in head/foot}%
\usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertminiframescurrentsection
\end{beamercolorbox}}%
\vskip0pt%
}
\setbeamertemplate{frametitle}
{%
\nointerlineskip%
\usebeamerfont{headline}%
\begin{beamercolorbox}[wd=\paperwidth,leftskip=.3cm,rightskip=.3cm plus1fil,vmode]{frametitle}
\vskip.5ex
\usebeamerfont*{frametitle}\insertframetitle%
\ifx\insertframesubtitle\@empty%
\strut\par%
\else
\par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
\fi%%
\usebeamerfont{headline}%
\vskip.5ex
\end{beamercolorbox}%
\nointerlineskip
\begin{beamercolorbox}[wd=\paperwidth,ht=.5ex,dp=0ex]{empty}
\pgfuseshading{beamer@belowframetitle}%
\end{beamercolorbox}%
}
\makeatother
\begin{document}
\section{Test}
\subsection{test1}
\begin{frame}{Title}one\end{frame}
\subsection{test1}
\frame{one}
\section{Test 2}
\subsection{test1}
\frame{one}
\frame{two}
\subsection{test1}
\frame{one}
\section{Test 3}
\subsection{test1}
\frame{one}
\frame{two}
\frame{three}
\subsection{test1}
\frame{one}
\end{document}
导航栏的代码\insertframescurrentsection
与默认的迷你框架导航非常相似(\insertnavigation
在beamerbasenavigation.sty
), 我只是删除了部分标题的显示,并添加了一个检查以确保只显示当前部分的迷你框架。
然后在 beamer 模板中使用这个“裸”迷你框架线headline
,它是标题的副本infolines
,其中子部分名称的显示被自定义导航栏替换。