如何对头部/脚部的投影仪部分/子部分的背景进行渐变着色?

如何对头部/脚部的投影仪部分/子部分的背景进行渐变着色?

这是我的代码的一个简化示例。我试图将 CambridgeUS 主题中的 head/foot 部分和 head/foot 子部分的背景重新设置为渐变背景颜色。

现在,如果我在 pgf 声明中指定 beamer@frametitleshade,渐变背景就可以正常工作。我找不到也猜不出正确的关键字来让它影响 head/foot 中部分的背景,也无法影响 head/foot 中子部分的背景,我尝试过 sectioninheadfootshade 和变体之类的东西。

\documentclass[hyperref={pdftex}]{beamer}
\useoutertheme{shadow}
\definecolor {Burgandy}{HTML}{660033}
\definecolor {Crimson}{HTML}{990033}
\definecolor {Orange}{HTML}{ff9933}

\usetheme{CambridgeUS}

\colorlet{titleleft}{Burgandy}
\colorlet{titlemiddle}{Crimson}
\colorlet{titleright}{Orange}

\pgfdeclarehorizontalshading[titleleft,titlemiddle,titleright]
      {beamer@frametitleshade}{\paperheight}{
    color(0pt)=(titleleft);
    color(0.6\paperwidth)=(titlemiddle);
    color(\paperwidth)=(titleright)
  }

\title[Short Title]{Long title}
\subtitle{Sub title}
\date{\today}

\begin{document}
    \begin{titlepage}
    \end{titlepage}

    \begin{frame}{Slide 1}
          Content
    \end{frame}
\end{document}

答案1

您可以重新定义元素以使用与框架标题相同的颜色渐变。请将以下对 footline 的重新定义与原始定义进行比较,以beamerouterthemeinfolines.sty查看变化。您可以使用相同的方法来修改标题。

一个技巧:颜色的背景必须设置为空。

\documentclass[hyperref={pdftex}]{beamer}
\useoutertheme{shadow}
\usetheme{CambridgeUS}

\colorlet{titleleft}{red}
\colorlet{titlemiddle}{orange}
\colorlet{titleright}{yellow}

\pgfdeclarehorizontalshading[titleleft,titlemiddle,titleright]
      {beamer@frametitleshade}{\paperheight}{
    color(0pt)=(titleleft);
    color(0.6\paperwidth)=(titlemiddle);
    color(\paperwidth)=(titleright)
  }

\title[Short Title]{Long title}
\subtitle{Sub title}
\date{\today}
\author{test}

\setbeamercolor{author in head/foot}{parent=palette primary,bg=}
\setbeamercolor{title in head/foot}{parent=palette secondary,bg=}
\setbeamercolor{date in head/foot}{parent=palette tertiary,bg=}

\makeatletter
\setbeamertemplate{footline}
{
    \leavevmode%
    \setbox\beamer@tempbox=\hbox{%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
            \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
            \usebeamerfont{title in head/foot}\insertshorttitle
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
            \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
            \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
        \end{beamercolorbox}%
        }%
        \beamer@tempdim=\ht\beamer@tempbox%
        \advance\beamer@tempdim by 4pt%
        \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
            \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
            \pgfusepath{clip}
            \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
        \end{pgfpicture}
        \vskip-\beamer@tempdim%
        \box\beamer@tempbox%    
}%
\makeatother

\begin{document}
    \begin{titlepage}
    \end{titlepage}

\section{ble}
    \begin{frame}{Slide 1}
          Content
    \end{frame}
\end{document}

在此处输入图片描述


由于我的拖延症很严重,所以这里也放上标题

\documentclass[hyperref={pdftex}]{beamer}
\useoutertheme{shadow}
\usetheme{CambridgeUS}

\colorlet{titleleft}{red}
\colorlet{titlemiddle}{orange}
\colorlet{titleright}{yellow}

\pgfdeclarehorizontalshading[titleleft,titlemiddle,titleright]
      {beamer@frametitleshade}{\paperheight}{
    color(0pt)=(titleleft);
    color(0.6\paperwidth)=(titlemiddle);
    color(\paperwidth)=(titleright)
  }

\title[Short Title]{Long title}
\subtitle{Sub title}
\date{\today}
\author{test}

\setbeamercolor{author in head/foot}{parent=palette primary,bg=}
\setbeamercolor{title in head/foot}{parent=palette secondary,bg=}
\setbeamercolor{date in head/foot}{parent=palette tertiary,bg=}

\setbeamercolor{section in head/foot}{parent=palette primary,bg=}
\setbeamercolor{subsection in head/foot}{parent=palette secondary,bg=}

\makeatletter
\setbeamertemplate{footline}
{
    \leavevmode%
    \setbox\beamer@tempbox=\hbox{%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
            \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
            \usebeamerfont{title in head/foot}\insertshorttitle
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
            \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
            \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
        \end{beamercolorbox}%
        }%
        \beamer@tempdim=\ht\beamer@tempbox%
        \advance\beamer@tempdim by 4pt%
        \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
            \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
            \pgfusepath{clip}
            \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
        \end{pgfpicture}
        \vskip-\beamer@tempdim%
        \box\beamer@tempbox%    
}%

\setbeamertemplate{headline}
{
    \leavevmode%
    \setbox\beamer@tempbox=\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}\insertsubsectionhead
        \end{beamercolorbox}%
        }%
        \beamer@tempdim=\ht\beamer@tempbox%
        \advance\beamer@tempdim by 4pt%
        \vskip-\beamer@tempdim%
        \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
            \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
            \pgfusepath{clip}
            \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
        \end{pgfpicture}
        \vskip-\beamer@tempdim%
        \box\beamer@tempbox%    
        \vskip0pt%
}
\makeatother

\begin{document}
    \begin{titlepage}
    \end{titlepage}

\section{ble}
\subsection{bla}
    \begin{frame}{Slide 1}
          Content
    \end{frame}
\end{document}

在此处输入图片描述

相关内容