在 beamer 中使用徽标自定义框架的标题

在 beamer 中使用徽标自定义框架的标题

我正在尝试在演示文稿的每个框架标题中添加徽标并添加垂直渐变。最后,我希望有这种类型的框架:

在此处输入图片描述

我已经尝试过此代码:\begin{frame} \frametitle{Title \hspace{12.2cm} \raisebox{\dimexpr \baselineskip - \totalheight}{\includegraphics[width=2cm]{example-image.png}}} \end{frame} 但它不是我想要的方式......

感谢您的帮助 !

答案1

有几个主题在框架标题中确实有渐变,例如华沙主题:

\documentclass{beamer}

\usetheme{Warsaw}
\usecolortheme{beaver}

\setbeamercolor{frametitle}{bg=lightgray}
\setbeamercolor{frametitle right}{bg=white}


\makeatletter

\setbeamertemplate{frametitle}{%
  \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]{.8\paperwidth}%
          \vbox{}\vskip-.75ex%
          \leftskip0.3cm%
          \rightskip0.3cm plus1fil\leavevmode
          \usebeamercolor[fg]{frametitle}\usebeamerfont{frametitle}\strut\insertframetitle\strut\par%
          \ifx\insertframesubtitle\@empty\else%
            {\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
          \fi%
          \nointerlineskip
          \vbox{}%
          \end{minipage}\begin{minipage}[b][.7cm][t]{.2\paperwidth}
          \hfill\includegraphics[height=0.7cm]{example-image-duck}\quad\mbox{}
          \end{minipage}}%
      \beamer@tempdim=\ht\beamer@tempbox%
      \advance\beamer@tempdim by 2pt%
      \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
        \begin{pgfscope}
          \pgfsetfillcolor{beamer@safeblack}%
          \pgfpathrectangle{\pgfpoint{0pt}{-4pt}}{\pgfpoint{\paperwidth}{8pt}}%
          \pgfsetfading{beamer@topshadowmask}{}%
          \pgfusepath{fill}%
        \end{pgfscope}
        \begin{pgfscope}
          \usebeamercolor{frametitle right}%
          \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}%
          \pgfusepath{clip}%
          \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}%
        \end{pgfscope}
      \end{pgfpicture}
      \hskip-\paperwidth%
      \box\beamer@tempbox%
    }%
    \hskip-\Gm@rmargin%
  }%
  \vskip-2pt
}
\makeatother

\begin{document}

\begin{frame}
\frametitle{title}
eee
\end{frame}
    
\end{document}

在此处输入图片描述

相关内容