我使用以下选项:
\usetheme{Frankfurt}
\setbeamercolor{section in head/foot}{fg=black, bg=white}
生成的幻灯片如下:
是否可以
- 让“第 1 部分”和“第 2 部分”更加紧密地结合在一起?
- 在框架标题前绘制分隔线?
答案1
当然可以。您可以重新定义模板;我使用高度和之前设置的颜色headline
制作了分隔线。beamercolorbox
.75ex
upper separation line head
\insertnavigation
我没有使用 ,而是使用了\insertsectionnavigationhorizontal
,因为它允许进行更多控制。我使用了颜色red
,因为您没有提供代码片段中使用的颜色方案的完整信息。您可以根据需要随意更改设置:
\documentclass{beamer}
\usetheme{Frankfurt}
\setbeamercolor{section in head/foot}{fg=black, bg=white}
\setbeamercolor{frametitle}{fg=red, bg=white}
\setbeamercolor{upper separation line head}{bg=red}
\makeatletter
\setbeamertemplate{headline}
{%
\pgfuseshading{beamer@barshade}%
\ifbeamer@sb@subsection%
\vskip-9.75ex%
\else%
\vskip-7ex%
\fi%
\begin{beamercolorbox}[ignorebg,ht=2.25ex,dp=3.75ex]{section in head/foot}
\insertsectionnavigationhorizontal{\paperwidth}{}{\hfill\hfill}
\end{beamercolorbox}%
\ifbeamer@sb@subsection%
\begin{beamercolorbox}[ignorebg,ht=2.125ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
\usebeamerfont{subsection in head/foot}\insertsubsectionhead
\end{beamercolorbox}%
\fi%
\begin{beamercolorbox}[colsep=1.5pt,ht=.75ex]{upper separation line head}
\end{beamercolorbox}
}%
\makeatother
\begin{document}
\section{Section One}
\begin{frame}
\frametitle{Test Frame One}
test
\end{frame}
\section{Section Two}
\begin{frame}
\frametitle{Test Frame Two}
test
\end{frame}
\end{document}
作为克劳迪奥·菲安德里诺在他的评论中提到,使用
\insertsectionnavigationhorizontal{\paperwidth}{\hskip0pt plus1fill}{\hskip0pt plus1fill}
代替
\insertsectionnavigationhorizontal{\paperwidth}{}{\hfill\hfill}
将在导航栏中产生居中部分。
以前的方法有一个缺点:不再包括小节的指标。为了恢复指标并使章节标题更接近,\insertnavigation
需要重新定义:
\documentclass{beamer}
\usetheme{Frankfurt}
\setbeamercolor{section in head/foot}{fg=black, bg=white}
\setbeamercolor{frametitle}{fg=red!70!black, bg=white}
\setbeamercolor{upper separation line head}{bg=red!70!black}
\makeatletter
\def\insertnavigation#1{%
\vbox{{%
\usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
\beamer@xpos=0\relax%
\beamer@ypos=1\relax%
\hbox to #1{\hskip.3cm\setbox\beamer@sectionbox=\hbox{\kern1sp}%
\ht\beamer@sectionbox=1.875ex%
\dp\beamer@sectionbox=0.75ex%
\hskip.3cm%
\global\beamer@section@min@dim\z@
\dohead%
\beamer@section@set@min@width
\box\beamer@sectionbox\hfill\hskip.3cm}%
}}}
\setbeamertemplate{headline}
{%
\pgfuseshading{beamer@barshade}%
\ifbeamer@sb@subsection%
\vskip-9.75ex%
\else%
\vskip-7ex%
\fi%
\begin{beamercolorbox}[ignorebg,ht=2.25ex,dp=3.75ex]{section in head/foot}
\insertnavigation{\paperwidth}
\end{beamercolorbox}%
\ifbeamer@sb@subsection%
\begin{beamercolorbox}[ignorebg,ht=2.125ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
\usebeamerfont{subsection in head/foot}\insertsubsectionhead
\end{beamercolorbox}%
\fi%
\begin{beamercolorbox}[colsep=1.5pt,ht=.75ex]{upper separation line head}
\end{beamercolorbox}
}%
\makeatother
\begin{document}
\section{Section One}
\subsection{Test Subsection One One}
\begin{frame}
\frametitle{Test Frame}
test
\end{frame}
\subsection{Test Subsection One Two}
\begin{frame}
\frametitle{Test Frame}
test
\end{frame}
\section{Section Two}
\subsection{Test Subsection Two One}
\begin{frame}
\frametitle{Test Frame}
test
\end{frame}
\subsection{Test Subsection Two Two}
\begin{frame}
\frametitle{Test Frame}
test
\end{frame}
\section{Section Three}
\subsection{Test Subsection Three One}
\begin{frame}
\frametitle{Test Frame}
test
\end{frame}
\subsection{Test Subsection Three Two}
\begin{frame}
\frametitle{Test Frame}
test
\end{frame}
\end{document}
答案2
还有一个有点 hack 的(或者说是务实的,如果你允许我出售它的话:P)版本是减少包含导航项目的 beamercolorbox 的长度。我实际上是从主题中复制粘贴了标题定义,smoothbars
并添加了 0.5 倍的系数。你可以根据部分的大小/数量调整它们应该展开多少。我只是从 Gonzalo 的答案中复制了线条解决方案。
\documentclass{beamer}
\usetheme{Frankfurt}
\setbeamercolor{upper separation line head}{bg=red}
\setbeamercolor{section in head/foot}{fg=black, bg=white}
\setbeamercolor{frametitle}{fg=red, bg=white}
\makeatletter
\setbeamertemplate{headline}
{%
\pgfuseshading{beamer@barshade}%
\ifbeamer@sb@subsection%
\vskip-9.75ex%
\else%
\vskip-7ex%
\fi%
\begin{beamercolorbox}[ignorebg,ht=2.25ex,dp=3.75ex]{section in head/foot}
\insertnavigation{0.5\paperwidth} % <======= Added 0.5 here
\end{beamercolorbox}%
\ifbeamer@sb@subsection%
\begin{beamercolorbox}[ignorebg,ht=2.125ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
\usebeamerfont{subsection in head/foot}\insertsubsectionhead
\end{beamercolorbox}%
\fi%
\begin{beamercolorbox}[colsep=1.5pt,ht=.75ex]{upper separation line head}
\end{beamercolorbox}
}%
\makeatother
\begin{document}
\section{Introduction}
\subsection{Subintro1}
\begin{frame}{Introduction}
Important Intro
\end{frame}
\subsection{Subintro2}
\begin{frame}{Dummy frame 1}{Subtitle} \end{frame}
\section{Main Course}
\subsection{Main}
\begin{frame}{Dummy frame 2} \end{frame}
\subsection{Course}
\begin{frame}{Dummy frame 3} \end{frame}
\section{Dessert}
\subsection{Wine}
\begin{frame}{Dummy frame 2} \end{frame}
\subsection{Coffee}
\begin{frame}{Dummy frame 3} \end{frame}
\end{document}