将标题框颜色更改为渐变色

将标题框颜色更改为渐变色

在 Beamer 中,我使用了主题Ann Arbor。我想在标题框上实现这种渐变颜色。

enter image description here

似乎我无法将框架标题背景更改为渐变色。我想将此部分(用红色圈出,带有箭头)更改为由青色变为黑色。[请忽略圈出的块]。我该怎么做?谢谢。

\documentclass[pdf]{beamer}
\mode<presentation>{\usetheme{AnnArbor}}
\usecolortheme{whale}
\setbeamercolor{section in toc}{fg=red}
%%%

\setbeamercolor{structure}{fg=cyan!80!black}
\setbeamercolor*{block title example}{fg=blue!50,bg= blue!10}
\setbeamercolor*{block body example}{fg= red,bg= blue!5}
\usefonttheme{structuresmallcapsserif}

\setbeamertemplate{footline}[page number]{} 

\setbeamercolor{headline}{fg=blue!90!black,bg=cyan!90!black}
\setbeamercolor{palette primary}{fg=white,bg=cyan!90!black}
\setbeamercolor{palette secondary}{fg=white,bg=cyan!90!black}
\setbeamercolor{palette tertiary}{fg=white,bg=black}
\setbeamercolor{frametitle}{fg=white,bg=cyan!50!black}
%%%%


\title{Some Random Stuff}
\subtitle{First time to code xD}

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



\begin{frame}{Testing}
\frametitle{Test}
Blah blah\\


\begin{block}{A block}
    Some text
\end{block}

\end{frame}

\end{document}

enter image description here

答案1

阴影框架标题的代码借用自beamerouterthemeshadow.sty。您可以调整线条的颜色\colorlet{titleleft}{cyan} \colorlet{titleright}{black}

\documentclass{beamer}

\mode<presentation>{\usetheme{AnnArbor}}
\usecolortheme{whale}

\setbeamercolor{frametitle}{parent=subsection in head/foot}
\setbeamercolor{frametitle right}{parent=section in head/foot}

\makeatletter
\pgfdeclarehorizontalshading[frametitle.bg,frametitle right.bg]{beamer@frametitleshade}{\paperheight}{%
    color(0pt)=(frametitle.bg);
    color(\paperwidth)=(frametitle right.bg)}

\AtBeginDocument{
    \pgfdeclareverticalshading{beamer@topshade}{\paperwidth}{%
        color(0pt)=(bg);
        color(4pt)=(black!50!bg)}
}

\addtobeamertemplate{headline}
{}
{%
    \vskip-0.2pt
    \pgfuseshading{beamer@topshade}
    \vskip-2pt
}


\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]{\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}}%
                \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

\setbeamercolor{section in toc}{fg=red}
%%%

\setbeamercolor{structure}{fg=cyan!80!black}
\setbeamercolor*{block title example}{fg=blue!50,bg= blue!10}
\setbeamercolor*{block body example}{fg= red,bg= blue!5}
\usefonttheme{structuresmallcapsserif}

\setbeamertemplate{footline}[page number]{} 

\setbeamercolor{headline}{fg=blue!90!black,bg=cyan!90!black}
\setbeamercolor{palette primary}{fg=white,bg=cyan!90!black}
\setbeamercolor{palette secondary}{fg=white,bg=cyan!90!black}
\setbeamercolor{palette tertiary}{fg=white,bg=black}
\setbeamercolor{frametitle}{fg=white,bg=cyan!50!black}


\colorlet{titleleft}{cyan}
\colorlet{titleright}{black}

\setbeamercolor*{frametitle}{fg=white}

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

\begin{document}

    \begin{frame}
        \frametitle{Test title}
        Test frame
    \end{frame}

\end{document}

enter image description here

相关内容