Beamer 模板的颜色

Beamer 模板的颜色

我在网上找到了下面的代码。我怎样才能改变它的颜色?(即黄色变成绿色,灰色变成浅绿色,标题中的两个水平条也变成深绿色)。代码如下:

\documentclass[10pt,xcolor={dvipsnames}]{beamer}

\mode<article> % only for the article version
{
  \usepackage{fullpage}
  \usepackage{hyperref}
}

\makeatletter

\usecolortheme{rose}

\definecolor{progressbar@bgblue}{rgb}{0.75,0.75,0.95} % use structure theme to change
\definecolor{progressbar@fgblue}{rgb}{0.1,0.1,0.9} % use structure theme to change

\setbeamercolor*{palette primary}{fg=progressbar@fgblue,bg=progressbar@bgblue}
\setbeamercolor*{palette secundary}{fg=progressbar@fgblue,bg=progressbar@bgblue}
\setbeamercolor*{palette tertiary}{fg=progressbar@fgblue,bg=progressbar@bgblue}

\setbeamercolor{section in head/foot}{parent=palette primary}

\makeatother

\mode<presentation>

\usefonttheme{default}

\setbeamerfont{title}{size=\Large,series=\bfseries,parent=structure}

\setbeamertemplate{bibliography item}[mybibitem]
\setbeamerfont{bibliography entry author}{shape=\upshape,series=\bfseries,size=\normalsize}%
\setbeamerfont{bibliography entry title}{shape=\upshape,size=\small,series=\mdseries}
\setbeamerfont{bibliography entry journal}{shape=\upshape,size=\small,series=\mdseries}
\setbeamerfont{bibliography entry note}{shape=\upshape,size=\small,series=\mdseries}

\setbeamerfont{itemize/enumerate body}{size=\small}
\setbeamerfont{itemize/enumerate subbody}{size=\footnotesize}
\setbeamerfont{itemize/enumerate subsubbody}{size=\scriptsize}

\setbeamerfont{block title}{size=\normalsize,series=\bfseries,parent={structure,block body}}

\setbeamerfont{section in head/foot}{size=\tiny,series=\bfseries}
\renewcommand{\emph}[1]{\color{structure.fg}\textbf{#1}\color{fg}\xspace}

\setbeamerfont{section in toc}{parent=structure,series=\bfseries}

\mode
<all>

\RequirePackage{tikz}

\useinnertheme{rounded}

\defbeamertemplate*{bibliography item}{progressbar theme}{
  \begin{tikzpicture}
    \useasboundingbox (0, 0.2) rectangle (0.5, 0.7);
    \fill[fill=bg!85!blue] (0, 0.25) rectangle (0.4, 0.5);
    \shade[bottom color=bg,top color=bg!85!blue] (0, 0) -- (0.3, 0) -- (0.4, 0.12) -- (0.4, 0.3) -- (0, 0.3) -- cycle;
    \shade[left color=bg,right color=bg!85!blue] (0,0.27) .. controls (0.25,0.25) .. (0.4,0.5) -- (0,0.5) -- cycle;
    \fill[fill=bg!90!blue] (0,0) rectangle (0.3,0.05);
    \shade[left color=bg!95!blue,right color=bg!90!blue] (0,0) rectangle (0.05,0.5);
    \shade[left color=bg,right color=bg!80!black,shading angle=45] (0.3,0) -- (0.3,0.12) -- (0.4,0.12) -- cycle;
    \draw[draw=fg!35!bg] (0,0) -- (0.3,0) -- (0.4,0.12) -- (0.4,0.5) -- (0,0.5) -- cycle;
    \draw[draw=fg!35!bg](0.3,0) -- (0.3,0.12) -- (0.4,0.12);
  \end{tikzpicture}
}


\defbeamertemplate*{frametitle}{progressbar theme}{
  \begin{centering}
    \textbf{\insertframetitle}
    \par
  \end{centering}
}

\mode<all>

\makeatletter

\RequirePackage{tikz}

\setbeamercolor{progressbar primary}{parent=palette primary}
\setbeamercolor{progressbar secondary}{parent=palette secondary}
\setbeamercolor{progressbar tertiary}{parent=palette tertiary}
\setbeamercolor{progressbar quaternary}{parent=palette quaternary}

\newdimen\progressbar@currentbarlength
\newdimen\progressbar@framenumberrectangle
\newdimen\progressbar@titlerectangle
\newdimen\progressbar@leftbar
\newdimen\progressbar@barlengthmm

\newcount\progressbar@tmpresult
\newcount\progressbar@numer
\newcount\progressbar@denom
\newcount\progressbar@barlength

\progressbar@framenumberrectangle=\paperwidth
\progressbar@titlerectangle=\paperwidth

\advance\progressbar@framenumberrectangle by -0.9cm
\advance\progressbar@titlerectangle by -1.1cm

\progressbar@barlength=115 % (in millimeters)
\progressbar@barlengthmm=\progressbar@barlength mm
\progressbar@leftbar=\progressbar@titlerectangle
\advance\progressbar@leftbar by -\progressbar@barlength mm

\def\insertprogressbar{
  \ifnum\inserttotalframenumber=1\else
    \progressbar@numer=\insertframenumber
    \advance\progressbar@numer by -1
    \progressbar@denom=\inserttotalframenumber
    \advance\progressbar@denom by -1
    \progressbar@tmpresult=\progressbar@barlength
    \multiply\progressbar@tmpresult by \progressbar@numer
    \divide\progressbar@tmpresult by \progressbar@denom
    \progressbar@currentbarlength=\progressbar@tmpresult mm

    \begin{tikzpicture}
      \shade[top color=bg, bottom color=bg!80!fg] (0, 0) rectangle  (\paperwidth, 0.6cm);
      \shade[left color=bg,right color=bg!70!fg] (.5\paperwidth, 0.2cm) rectangle (\paperwidth, 0.22cm);
      \draw (\progressbar@framenumberrectangle, 0.21cm) node [anchor=mid west, draw=bg!70!fg, fill=bg] {\color{structure.fg!70!bg}\scalebox{0.85}{\insertframenumber/\inserttotalframenumber}};
      \draw (\progressbar@titlerectangle, 0.32cm) node [anchor=south east] {\color{bg!70!fg}Teoremas limite fortes para somas de vari\'{a}veis aleat\'{o}rias};
      \fill (\progressbar@leftbar, 0.12cm) [fill=bg, rounded corners=0.1cm] rectangle (\progressbar@titlerectangle, 0.3cm);
      \ifnum\insertframenumber=1\else
      \shade[left color=progressbar primary.fg!10!bg, right color=progressbar primary.fg!20!bg, rounded corners=0.1cm] (\progressbar@leftbar, 0.12cm) rectangle ++(\progressbar@currentbarlength, 0.2cm);
      \fi
      \draw (\progressbar@leftbar, 0.11cm) [draw=bg!70!fg, rounded corners=0.1cm] rectangle ++(\progressbar@barlengthmm, 0.2cm);
    \end{tikzpicture}
  \fi
}

\mode<presentation>

\newlength\progressbar@sectionboxwidth
\newlength\progressbar@sectionboxheight
\newbox\progressbar@sectionbox
\newbox\progressbar@sectionboxbox

\usesectionheadtemplate
  {\hfill
    \setbox\progressbar@sectionbox=\hbox{\insertsectionhead}%
    \progressbar@sectionboxwidth=\wd\progressbar@sectionbox
    \advance\progressbar@sectionboxwidth by 4pt
    \setbox\progressbar@sectionbox=\hbox{\pgfinterruptpicture t \endpgfinterruptpicture}%
    \progressbar@sectionboxheight=\ht\progressbar@sectionbox
    \advance\progressbar@sectionboxheight by 4pt
    \begin{tikzpicture}
      \useasboundingbox (-0.5\progressbar@sectionboxwidth, 0pt) rectangle (0.5\progressbar@sectionboxwidth, \progressbar@sectionboxheight);
      \draw[anchor=base] (0pt, 2pt) node {\color{structure.fg!80!bg} \insertsectionhead};
    \end{tikzpicture}
  }
  {\hfill
    \setbox\progressbar@sectionbox=\hbox{\pgfinterruptpicture\insertsectionhead\endpgfinterruptpicture}%
    \progressbar@sectionboxwidth=\wd\progressbar@sectionbox
    \advance\progressbar@sectionboxwidth by 4pt
    \setbox\progressbar@sectionboxbox=\hbox{\pgfinterruptpicture t \endpgfinterruptpicture}%
    \progressbar@sectionboxheight=\ht\progressbar@sectionboxbox
    \advance\progressbar@sectionboxheight by 4pt
  }

\defbeamertemplate*{headline}{progressbar theme}
{%
  \leavevmode%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,dp=1.125ex]{section in head/foot}%
    \insertsectionnavigationhorizontal{\paperwidth}{}{}%\hskip0pt plus1filll}{}%
  \end{beamercolorbox}%
}

\defbeamertemplate*{footline}{progressbar theme}{
  \begin{beamercolorbox}[wd=\paperwidth,ht=0.6cm,dp=0ex]{progressbar in head/foot}%
    \insertprogressbar
  \end{beamercolorbox}%
}


\defbeamertemplate*{title page}{progressbar theme}{
  \pgfdeclarehorizontalshading{separationtitlepagelineshading}{0.5pt}{color(0cm)=(bg); color(0.5\textwidth)=(structure.fg); color(\textwidth)=(bg)}

  \makeatletter
  \begin{center}
    \textbf{\textcolor{structure.fg}\large\inserttitle}

    \pgfuseshading{separationtitlepagelineshading}
    \vskip\baselineskip
    \footnotesize\insertauthor\\[\baselineskip]
    \ifx\insertinstitute\@empty \else\tiny\insertinstitute\\[\baselineskip]\fi
    \insertlogo
    \vskip\baselineskip
    \pgfuseshading{separationtitlepagelineshading}
    \vfill
    \footnotesize
    \insertdate
  \end{center}
  \makeatother
}
\setbeamertemplate{title page}[mytitlepage]

\defbeamertemplate*{background canvas}{progressbar theme}{\pgfuseshading{background shading}}%[action]

\AtBeginDocument{%
  {
    \usebeamercolor{progressbar primary}
    \pgfdeclareverticalshading{background shading}{\the\paperwidth}{color(0cm)=(normal text.bg); color(0.8\paperheight)=(normal text.bg); color(0.95\paperheight)=(progressbar primary.bg); color(\paperheight)=(progressbar primary.bg)
    }
  }
}

\mode
<all>

\makeatother

\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{navigation symbols}{}

\mode<presentation>
{
  \setbeamercovered{transparent}
  \usefonttheme{serif}
  \usecolortheme{crane}
}

\setbeamercovered{dynamic}

\setbeamertemplate{items}[circle]

\title[]{\vspace*{0.5cm}\parbox{10.0cm}{\centering{\LARGE{\sc Title}}}}

\author{\parbox{10.0cm}{\vfill \relax\ifvmode\centering\fi {\normalsize\textbf{Author}} \vfill} \\[10pt] {\normalsize\textit{Filiation}}}

\date{{\footnotesize \vspace*{1.0cm} April 2023}}

\begin{document}

\begin{frame}[plain]

\maketitle

\end{frame}

\begin{frame}

My first slide

\end{frame}

\end{document}

提前致谢。

答案1

  • 要更改标题底纹的颜色,您可以使用\setbeamercolor{progressbar primary}{bg=green}\setbeamercolor{section in head/foot}{bg=green}

  • 标题页上的线条使用structure颜色,您可以像这样更改它:\setbeamercolor{structure}{fg=green!50!black}请注意,这将改变演示文稿中很多东西的颜色

  • 脚注中的灰色似乎是由文本和背景颜色混合计算得出的。如果您想单独更改它,可以在定义中选择另一种颜色\insertprogressbar


\documentclass[10pt,xcolor={dvipsnames}]{beamer}

\mode<article> % only for the article version
{
  \usepackage{fullpage}
  \usepackage{hyperref}
}

\makeatletter

\usecolortheme{rose}

\definecolor{progressbar@bgblue}{rgb}{0.75,0.75,0.95} % use structure theme to change
\definecolor{progressbar@fgblue}{rgb}{0.1,0.1,0.9} % use structure theme to change

\setbeamercolor*{palette primary}{fg=progressbar@fgblue,bg=progressbar@bgblue}
\setbeamercolor*{palette secundary}{fg=progressbar@fgblue,bg=progressbar@bgblue}
\setbeamercolor*{palette tertiary}{fg=progressbar@fgblue,bg=progressbar@bgblue}

\setbeamercolor{section in head/foot}{parent=palette primary}

\makeatother

\mode<presentation>

\usefonttheme{default}

\setbeamerfont{title}{size=\Large,series=\bfseries,parent=structure}

\setbeamertemplate{bibliography item}[mybibitem]
\setbeamerfont{bibliography entry author}{shape=\upshape,series=\bfseries,size=\normalsize}%
\setbeamerfont{bibliography entry title}{shape=\upshape,size=\small,series=\mdseries}
\setbeamerfont{bibliography entry journal}{shape=\upshape,size=\small,series=\mdseries}
\setbeamerfont{bibliography entry note}{shape=\upshape,size=\small,series=\mdseries}

\setbeamerfont{itemize/enumerate body}{size=\small}
\setbeamerfont{itemize/enumerate subbody}{size=\footnotesize}
\setbeamerfont{itemize/enumerate subsubbody}{size=\scriptsize}

\setbeamerfont{block title}{size=\normalsize,series=\bfseries,parent={structure,block body}}

\setbeamerfont{section in head/foot}{size=\tiny,series=\bfseries}
\renewcommand{\emph}[1]{\color{structure.fg}\textbf{#1}\color{fg}\xspace}

\setbeamerfont{section in toc}{parent=structure,series=\bfseries}

\mode
<all>

\RequirePackage{tikz}

\useinnertheme{rounded}

\defbeamertemplate*{bibliography item}{progressbar theme}{
  \begin{tikzpicture}
    \useasboundingbox (0, 0.2) rectangle (0.5, 0.7);
    \fill[fill=bg!85!blue] (0, 0.25) rectangle (0.4, 0.5);
    \shade[bottom color=bg,top color=bg!85!blue] (0, 0) -- (0.3, 0) -- (0.4, 0.12) -- (0.4, 0.3) -- (0, 0.3) -- cycle;
    \shade[left color=bg,right color=bg!85!blue] (0,0.27) .. controls (0.25,0.25) .. (0.4,0.5) -- (0,0.5) -- cycle;
    \fill[fill=bg!90!blue] (0,0) rectangle (0.3,0.05);
    \shade[left color=bg!95!blue,right color=bg!90!blue] (0,0) rectangle (0.05,0.5);
    \shade[left color=bg,right color=bg!80!black,shading angle=45] (0.3,0) -- (0.3,0.12) -- (0.4,0.12) -- cycle;
    \draw[draw=fg!35!bg] (0,0) -- (0.3,0) -- (0.4,0.12) -- (0.4,0.5) -- (0,0.5) -- cycle;
    \draw[draw=fg!35!bg](0.3,0) -- (0.3,0.12) -- (0.4,0.12);
  \end{tikzpicture}
}


\defbeamertemplate*{frametitle}{progressbar theme}{
  \begin{centering}
    \textbf{\insertframetitle}
    \par
  \end{centering}
}

\mode<all>

\makeatletter

\RequirePackage{tikz}

\setbeamercolor{progressbar primary}{parent=palette primary}
\setbeamercolor{progressbar secondary}{parent=palette secondary}
\setbeamercolor{progressbar tertiary}{parent=palette tertiary}
\setbeamercolor{progressbar quaternary}{parent=palette quaternary}

\newdimen\progressbar@currentbarlength
\newdimen\progressbar@framenumberrectangle
\newdimen\progressbar@titlerectangle
\newdimen\progressbar@leftbar
\newdimen\progressbar@barlengthmm

\newcount\progressbar@tmpresult
\newcount\progressbar@numer
\newcount\progressbar@denom
\newcount\progressbar@barlength

\progressbar@framenumberrectangle=\paperwidth
\progressbar@titlerectangle=\paperwidth

\advance\progressbar@framenumberrectangle by -0.9cm
\advance\progressbar@titlerectangle by -1.1cm

\progressbar@barlength=115 % (in millimeters)
\progressbar@barlengthmm=\progressbar@barlength mm
\progressbar@leftbar=\progressbar@titlerectangle
\advance\progressbar@leftbar by -\progressbar@barlength mm

\def\insertprogressbar{
  \ifnum\inserttotalframenumber=1\else
    \progressbar@numer=\insertframenumber
    \advance\progressbar@numer by -1
    \progressbar@denom=\inserttotalframenumber
    \advance\progressbar@denom by -1
    \progressbar@tmpresult=\progressbar@barlength
    \multiply\progressbar@tmpresult by \progressbar@numer
    \divide\progressbar@tmpresult by \progressbar@denom
    \progressbar@currentbarlength=\progressbar@tmpresult mm

    \begin{tikzpicture}
      \shade[top color=bg, bottom color=green!80!fg] (0, 0) rectangle  (\paperwidth, 0.6cm);
      \shade[left color=bg,right color=bg!70!fg] (.5\paperwidth, 0.2cm) rectangle (\paperwidth, 0.22cm);
      \draw (\progressbar@framenumberrectangle, 0.21cm) node [anchor=mid west, draw=bg!70!fg, fill=bg] {\color{structure.fg!70!bg}\scalebox{0.85}{\insertframenumber/\inserttotalframenumber}};
      \draw (\progressbar@titlerectangle, 0.32cm) node [anchor=south east] {\color{bg!70!fg}Teoremas limite fortes para somas de vari\'{a}veis aleat\'{o}rias};
      \fill (\progressbar@leftbar, 0.12cm) [fill=bg, rounded corners=0.1cm] rectangle (\progressbar@titlerectangle, 0.3cm);
      \ifnum\insertframenumber=1\else
      \shade[left color=progressbar primary.fg!10!bg, right color=progressbar primary.fg!20!bg, rounded corners=0.1cm] (\progressbar@leftbar, 0.12cm) rectangle ++(\progressbar@currentbarlength, 0.2cm);
      \fi
      \draw (\progressbar@leftbar, 0.11cm) [draw=bg!70!fg, rounded corners=0.1cm] rectangle ++(\progressbar@barlengthmm, 0.2cm);
    \end{tikzpicture}
  \fi
}

\mode<presentation>

\newlength\progressbar@sectionboxwidth
\newlength\progressbar@sectionboxheight
\newbox\progressbar@sectionbox
\newbox\progressbar@sectionboxbox

\usesectionheadtemplate
  {\hfill
    \setbox\progressbar@sectionbox=\hbox{\insertsectionhead}%
    \progressbar@sectionboxwidth=\wd\progressbar@sectionbox
    \advance\progressbar@sectionboxwidth by 4pt
    \setbox\progressbar@sectionbox=\hbox{\pgfinterruptpicture t \endpgfinterruptpicture}%
    \progressbar@sectionboxheight=\ht\progressbar@sectionbox
    \advance\progressbar@sectionboxheight by 4pt
    \begin{tikzpicture}
      \useasboundingbox (-0.5\progressbar@sectionboxwidth, 0pt) rectangle (0.5\progressbar@sectionboxwidth, \progressbar@sectionboxheight);
      \draw[anchor=base] (0pt, 2pt) node {\color{structure.fg!80!bg} \insertsectionhead};
    \end{tikzpicture}
  }
  {\hfill
    \setbox\progressbar@sectionbox=\hbox{\pgfinterruptpicture\insertsectionhead\endpgfinterruptpicture}%
    \progressbar@sectionboxwidth=\wd\progressbar@sectionbox
    \advance\progressbar@sectionboxwidth by 4pt
    \setbox\progressbar@sectionboxbox=\hbox{\pgfinterruptpicture t \endpgfinterruptpicture}%
    \progressbar@sectionboxheight=\ht\progressbar@sectionboxbox
    \advance\progressbar@sectionboxheight by 4pt
  }

\defbeamertemplate*{headline}{progressbar theme}
{%
  \leavevmode%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,dp=1.125ex]{section in head/foot}%
    \insertsectionnavigationhorizontal{\paperwidth}{}{}%\hskip0pt plus1filll}{}%
  \end{beamercolorbox}%
}

\defbeamertemplate*{footline}{progressbar theme}{
  \begin{beamercolorbox}[wd=\paperwidth,ht=0.6cm,dp=0ex]{progressbar in head/foot}%
    \insertprogressbar
  \end{beamercolorbox}%
}


\defbeamertemplate*{title page}{progressbar theme}{
  \pgfdeclarehorizontalshading{separationtitlepagelineshading}{0.5pt}{color(0cm)=(bg); color(0.5\textwidth)=(structure.fg); color(\textwidth)=(bg)}

  \makeatletter
  \begin{center}
    \textbf{\textcolor{structure.fg}\large\inserttitle}

    \pgfuseshading{separationtitlepagelineshading}
    \vskip\baselineskip
    \footnotesize\insertauthor\\[\baselineskip]
    \ifx\insertinstitute\@empty \else\tiny\insertinstitute\\[\baselineskip]\fi
    \insertlogo
    \vskip\baselineskip
    \pgfuseshading{separationtitlepagelineshading}
    \vfill
    \footnotesize
    \insertdate
  \end{center}
  \makeatother
}
\setbeamertemplate{title page}[mytitlepage]

\defbeamertemplate*{background canvas}{progressbar theme}{\pgfuseshading{background shading}}%[action]

\AtBeginDocument{%
  {
    \usebeamercolor{progressbar primary}
    \pgfdeclareverticalshading{background shading}{\the\paperwidth}{color(0cm)=(normal text.bg); color(0.8\paperheight)=(normal text.bg); color(0.95\paperheight)=(progressbar primary.bg); color(\paperheight)=(progressbar primary.bg)
    }
  }
}

\mode
<all>

\makeatother

\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{navigation symbols}{}

\mode<presentation>
{
  \setbeamercovered{transparent}
  \usefonttheme{serif}
  \usecolortheme{crane}
}

\setbeamercovered{dynamic}

\setbeamertemplate{items}[circle]

\title[]{\vspace*{0.5cm}\parbox{10.0cm}{\centering{\LARGE{\sc Title}}}}

\author{\parbox{10.0cm}{\vfill \relax\ifvmode\centering\fi {\normalsize\textbf{Author}} \vfill} \\[10pt] {\normalsize\textit{Filiation}}}

\date{{\footnotesize \vspace*{1.0cm} April 2023}}


\setbeamercolor{progressbar primary}{bg=green}
\setbeamercolor{section in head/foot}{bg=green}
\setbeamercolor{structure}{fg=green!50!black}
%\setbeamercolor{normal text}{bg=red}


\begin{document}

\begin{frame}[plain]

\maketitle

\end{frame}

\begin{frame}

My first slide

\end{frame}

\end{document}

相关内容