将导航栏与标题和副标题合并

将导航栏与标题和副标题合并

我的幻灯片顶部有标题和副标题(我删除了标题栏)。但是,我想将导航栏(仅用于部分)放在标题和副标题行的右角。下面显示了第一张幻灯片。但是,这很混乱,因为它会改变栏的大小,并且字体类型和大小不一致。

  1. 我该如何正确调整它以使其保留幻灯片 2 的条的大小?
  2. 有没有办法为所有幻灯片创建此功能?到目前为止,我是通过在每张幻灯片的标题上写上它来实现的,如下所示。

梅威瑟:

\documentclass[10pt]{beamer}
\usetheme{Warsaw}
\usefonttheme[onlymath]{serif}
\setbeamertemplate{footline}{}
\setbeamertemplate{headline}{}
\setbeamertemplate{section in head/foot}
{ %
\fontsize{20}{25}
}
\setbeamertemplate{navigation symbols}{}

\begin{document}

\section{Section 1}
\begin{frame}{Topic 1 \hfill \insertsectionnavigation{2cm}}
\framesubtitle{Frame 1}
Frame 1
\end{frame}
\section{Section 2}
\begin{frame}{Topic 2}
\framesubtitle{Frame 2}
Frame 2
\end{frame}
\end{document}

答案1

您可以frametitle按照shadow外部主题(由 内部使用Warsaw)的定义重新定义模板,以包含导航栏。主题使用minipage宽度为width 的 来显示标题和副标题\paperwidth,因此我将宽度更改为0.5\paperwidth并添加了另一个minipage相同宽度的 来添加导航栏;当然,您可以随意进行修改以更好地满足您的需求:

\documentclass[10pt]{beamer}
\usetheme{Warsaw}
\usefonttheme[onlymath]{serif}
\setbeamertemplate{footline}{}
\setbeamertemplate{headline}{}
\setbeamertemplate{section in head/foot}
{ %
\fontsize{20}{25}
}
\setbeamertemplate{navigation symbols}{}

\makeatletter
\defbeamertemplate*{frametitle}{myshadow theme}
{%
  \nointerlineskip%
  \vskip-2pt%
  \hbox{\leavevmode
    \advance\beamer@leftmargin by -12bp%
    \advance\beamer@rightmargin by -12bp%
    \beamer@tempdim=\textwidth%
    \advance\beamer@tempdim by \beamer@leftmargin%
    \advance\beamer@tempdim by \beamer@rightmargin%
    \hskip-\Gm@lmargin\hbox{%
      \setbox\beamer@tempbox=\hbox{\begin{minipage}[b]{.5\paperwidth}%
          \vbox{}\vskip-.75ex%
          \leftskip0.3cm%
          \rightskip0.3cm plus1fil\leavevmode
          \insertframetitle%
          \ifx\insertframesubtitle\@empty%
            \strut\par%
          \else
            \par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
          \fi%
          \nointerlineskip
          \vbox{}%
          \end{minipage}%
          \begin{minipage}[b]{.5\paperwidth}
            \hfill\raisebox{0.5\height}[0pt][0pt]{%
              \insertsectionnavigationhorizontal{.5\paperwidth}{\hskip1em}{\hskip1em}%
              }%
          \end{minipage}%
          }%
      \beamer@tempdim=\ht\beamer@tempbox%
      \advance\beamer@tempdim by 2pt%
      \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
        \usebeamercolor{frametitle right}
        \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
        \pgfusepath{clip}
        \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
      \end{pgfpicture}
      \hskip-\paperwidth%
      \box\beamer@tempbox%
    }%
    \hskip-\Gm@rmargin%
  }%
  \nointerlineskip
    \vskip-0.2pt
    \hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@topshade}\hskip-\Gm@rmargin}
    \vskip-2pt
}
\makeatother

\begin{document}

\section{Section 1}
\begin{frame}{Topic 1}
\framesubtitle{Frame 1}
Frame 1
\end{frame}

\section{Section 2}
\begin{frame}{Topic 2}
\framesubtitle{Frame 2}
Frame 2
\end{frame}

\section{Section 3}
\begin{frame}{Topic 3}
\framesubtitle{Frame 3}
Frame 2
\end{frame}

\end{document}

生成的文档的图像:

在此处输入图片描述

相关内容