使用 .sty 文件更改 Beamer \titlepage 的颜色

使用 .sty 文件更改 Beamer \titlepage 的颜色

我一直在到处寻找答案,但到目前为止,似乎没有任何效果。我想做的是更改命令的背景颜色和字体颜色\titlepage,但要在我生成的自定义文件中进行更改.sty,也就是说,我不想在文件中指定颜色的更改.tex

(希望尽可能基本的).tex文件大纲是(有些行被注释掉以确保示例可以在没有额外文件的情况下运行 - 如果您希望添加自己的文件来查看其运行,请随意!):

    \documentclass{beamer}
    \usetheme{Oxford}

    \usepackage{color,graphicx}
    \usepackage{epsfig} % Modifies table/figure captions
    \DeclareGraphicsExtensions{.pdf,.png,.jpg}

    \author{Author Name}
    \title{Presentation Title}
    \institute{Institute Name}

    \date{}

    \begin{document}
       \begin{frame}[plain]
          \titlepage
       \end{frame}

       \begin{frame}
          \frametitle{Outline}
          \tableofcontents
       \end{frame}

       \section{Example Section}
       \begin{frame}
          \frametitle{Example Frame}
       \end{frame}

       \section{Second Example}
       \begin{frame}
          \frametitle{Example Frame With a Block}
          \begin{block}{Test Block}
             Testing the block colour here\ldots{}
          \end{block}
       \end{frame}
    \end{document}

关联beamerthemeOxford.sty文件如下:

    \DeclareOptionBeamer{compress}{\beamer@compresstrue}
    \ProcessOptionsBeamer
    \mode<presentation>

    \useoutertheme[footline=authortitle]{miniframes}
    \useinnertheme{circles}
    \usecolortheme{whale}
    \usecolortheme{orchid}

    % Define the colours that are to be used in the presentation
    \definecolor{oxfordblue}{RGB}{0,33,71}          % Oxford Blue
    \definecolor{oxfordgold}{cmyk}{0,0.21,0.60,0.30}    % Oxford Gold

    % Set which colours apply to which structures
    \setbeamercolor{structure}{fg=oxfordblue}
    \setbeamercolor{titlelike}{parent=structure}
    \setbeamercolor{frametitle}{fg=oxfordblue}
    \setbeamercolor{title}{fg=oxfordblue}
    \setbeamercolor{item}{fg=oxfordblue}
    \setbeamercolor{section in head/foot}{bg=oxfordblue,fg=white}

    % Define the headline and titlebar
    \setbeamertemplate{headline}
    {
       \begin{beamercolorbox}[wd=1\paperwidth,left]{section in head/foot}
       \vskip2pt
       \insertnavigation{0.85\paperwidth}
       \vskip2pt
       \end{beamercolorbox}
    }

    \usepackage{tikz}
    \usetikzlibrary{backgrounds}
    \usepackage[absolute,overlay]{textpos} 
    % \pgfdeclareimage[height=1.1cm]{logo}{logo_file}
    \setlength{\TPHorizModule}{\paperwidth}
    \setlength{\TPVertModule}{\paperheight}
    \setbeamertemplate{frametitle}
    {
       \vskip-1pt
       \begin{beamercolorbox}[wd=1\paperwidth,left]{section in head/foot}
          \vskip-15pt
          \begin{tikzpicture}
             \shade[left color=white,right  color=oxfordblue] (0,0) rectangle +(11,0.02);
          \end{tikzpicture}
          \vskip-2pt
          \hskip10pt\strut\insertframetitle\strut\\
       \end{beamercolorbox} 
       \begin{textblock}{0.2}[0.5,0.5](0.99,0.07)
          % \pgfuseimage{logo}
       \end{textblock} 
    }

    % Adapt other segments of code
    \setbeamertemplate{blocks}[rounded][shadow=true]
    \setbeamertemplate{navigation symbols}{}

    % Ensures navigation circles are displayed
    \usepackage{remreset}
    \makeatletter
    \@removefromreset{subsection}{section}
    \makeatother
    \setcounter{subsection}{1}

    % Reformat Title Page to our own specifications
    \setbeamertemplate{title page}
    {
    \setbeamercolor*{background canvas}{fg=oxfordblue,bg=oxfordblue}
    %   \setbeamercolor*{title}{fg=oxfordblue,bg=oxfordblue}
    %   \setbeamercolor{titlelike}{parent=structure}
       \begin{columns}
          \column{0.7\textwidth}
          \usebeamerfont{title}\inserttitle
          \ifx\insertsubtitle\@empty
          \else
             \vskip2ex
             \usebeamerfont{subtitle}\insertsubtitle
          \fi
          \ifx\insertauthor\@empty
          \else
             \vskip2ex
             \usebeamerfont{author}\insertauthor
          \fi
          \ifx\insertdate\@empty
          \else
             \vskip2ex
             \usebeamerfont{date}\insertdate%
          \fi
          \ifx\insertinstitute\@empty
          \else
             \vskip2ex
             \usebeamerfont{institute}\insertinstitute%
          \fi
          \vfill
          \column{0.3\textwidth}
          % \includegraphics[width=0.5\textwidth]{pic1}\\
          \vskip5pt
          % \includegraphics[width=0.5\textwidth]{pic2}\\
          \vskip5pt
          % \includegraphics[width=0.5\textwidth]{pic3}
       \end{columns}
    }

    \mode
    <all>

我尝试了各种其他方法,但都无济于事,而且都是拙劣的拼凑物。无论哪种情况,标题页的背景颜色都保持为白色,而我希望背景为 ,oxfordblue字体为white。有人知道我做错了什么吗?

感谢您的帮助。

答案1

好问题!说实话,我不知道答案,但我在自己的样式文件中使用了一种变通方法。在文件中.sty,我为 titlepage 定义了一个包装器宏,类似于

      \newcommand{\insertoxfordtitle}{%
        \setbeamercolor*{background canvas}{fg=oxfordblue,bg=oxfordblue}
        \begin{frame}[plain]
        \titlepage
      \end{frame}
      \setbeamercolor{background canvas}{fg=oxfordblue,bg=white}
    }

.tex文件中,我用 替换了标题框\insertoxfordtitle

文件相关修改.sty

    % Reformat Title Page to our own specifications
    \setbeamercolor{title}{fg=white}
    \setbeamercolor*{subtitle}{fg=white}
    \setbeamercolor*{date}{fg=white}

      \newcommand{\insertoxfordtitle}{%
        \setbeamercolor*{background canvas}{fg=oxfordblue,bg=oxfordblue}
        \begin{frame}[plain]
        \titlepage
      \end{frame}
      \setbeamercolor{background canvas}{fg=oxfordblue,bg=white}
    }

   \setbeamertemplate{title page}{
       \begin{columns}
          \column{0.7\textwidth}
          \usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle
          \ifx\insertsubtitle\@empty
          \else
             \vskip2ex
             \usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle
          \fi
          \ifx\insertauthor\@empty
          \else
             \vskip2ex
             \usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor
          \fi
          \ifx\insertdate\@empty
          \else
             \vskip2ex
             \usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate%
          \fi
          \ifx\insertinstitute\@empty
          \else
             \vskip2ex
             \usebeamerfont{institute}\usebeamercolor[fg]{institut}\insertinstitute%
          \fi
          \vfill
          \column{0.3\textwidth}
          % \includegraphics[width=0.5\textwidth]{pic1}\\
          \vskip5pt
          % \includegraphics[width=0.5\textwidth]{pic2}\\
          \vskip5pt
          % \includegraphics[width=0.5\textwidth]{pic3}
       \end{columns}
    }

在此处输入图片描述

答案2

由于示例已经加载,tikz因此也可以使用它在标题页上绘制彩色矩形:

\documentclass{beamer}

\usepackage{tikz}
\definecolor{oxfordblue}{RGB}{0,33,71} 

\setbeamertemplate{title page}
{
    \begin{tikzpicture}[remember picture,overlay]
        \node[at=(current page.center),fill=oxfordblue, minimum width=\paperwidth, minimum height=\paperheight] {};
    \end{tikzpicture}
    However you would normally define your title page
}

\begin{document}

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

\end{document}

要在.sty文件中使用此解决方案,只需复制\setbeamertemplate{title page}{...}其中的所有内容。

答案3

一个解决方案是创建用于标题页的专用页面样式。

在下面的文件中,专用的页面样式称为navigation@titlepage。您可以在此处添加任何要应用于标题页的修改。作为示例,我们按照 OP 的要求添加了一个蓝色背景。

\documentclass{beamer}

\author{Author Name}
\title{Presentation Title}
\institute{Institute Name}
\date{}

\definecolor{oxfordblue}{RGB}{0,33,71} 


\makeatletter
\def\ps@navigation@titlepage{%
  % Add here all the changes you want to apply to the title page
  \setbeamercolor{background canvas}{bg=oxfordblue}%  blue background
  \@nameuse{ps@navigation}}

\addtobeamertemplate{title page}{\thispagestyle{navigation@titlepage}}{}
\makeatother


\begin{document}

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

\begin{frame}
  \frametitle{Outline}
  \tableofcontents
\end{frame}

\section{Example Section}

\begin{frame}
  \frametitle{Example Frame}
\end{frame}

\section{Second Example}

\begin{frame}
  \frametitle{Example Frame With a Block}
  \begin{block}{Test Block}
    Testing the block colour here\ldots{}
  \end{block}
\end{frame}

\end{document}

在此处输入图片描述

在此处输入图片描述

相关内容