设置标题背景颜色

设置标题背景颜色

我试图将演示文稿第一页的标题(仅标题(带有一些边距),而不是整个页面)的背景颜色设为“greyone”。此背景框应为页面宽度,而文本应居中。我还没搞清楚该怎么做……

我在序言中定义了一个新的 beamer 模板

\documentclass['serif]{beamer}
\usecolortheme{eelke}
% INFORMATION
\title{Presentation Title}
\author{A. Uthor}
% FRONTPAGE
\defbeamertemplate*{title page}{eelke}[1]
{
\centering
\usebeamerfont{title}\inserttitle\par % this should have a background box in color grayone. Text should be white for readability.
\vskip20pt
\usebeamercolor[bg]{titlelike}
\setbeamerfont{author}{size=\fontsize{11}{15}}
\usebeamerfont{author}\insertauthor\par %
\vskip20pt
\setbeamerfont{date}{size=\fontsize{11}{15}}
\usebeamerfont{date}\insertdate\par} \begin{document}\begin{frame}\maketitle\end{frame}\end{document}

`

此外,我在 beamercolorthemeeelke.sty 文件中定义了一种新颜色

\definecolor{greyone}{RGB}{77,77,77}
\setbeamercolor{palette quaternary}{fg=white,bg=greyone, wd=\paperwidth}
\setbeamercolor{titlelike}{parent=palette quaternary}

序言中提到了这一点:\usecolortheme{eelke}

谁能帮我吗?

编辑:添加 MAW

答案1

您可以使用beamercolorbox但与beamerleftmargin先前beamerrightmargin添加到的和textwidth

\documentclass['serif]{beamer}
%\usecolortheme{eelke}

\definecolor{greyone}{RGB}{77,77,77}
\setbeamercolor{palette quaternary}{fg=white,bg=greyone}
\setbeamercolor{titlelike}{parent=palette quaternary}

% INFORMATION
\title{Presentation Title}
\author{A. Uthor}
% FRONTPAGE
\makeatletter
\defbeamertemplate*{title page}{eelke}[1]
{
\@tempdima=\textwidth%
\advance\@tempdima by \beamer@leftmargin%
\advance\@tempdima by \beamer@rightmargin%
\begin{beamercolorbox}[sep=1em,wd=\the\@tempdima]{titlelike}
\centering
\usebeamerfont{title}\inserttitle\par % this should have a background box in color grayone. Text should be white for readability.
\end{beamercolorbox}
\vskip20pt
\usebeamercolor[bg]{titlelike}
\setbeamerfont{author}{size=\fontsize{11}{15}}
\usebeamerfont{author}\insertauthor\par %
\vskip20pt
\setbeamerfont{date}{size=\fontsize{11}{15}}
\usebeamerfont{date}\insertdate\par} 
\makeatother

\begin{document}
\begin{frame}
\maketitle
\end{frame}
\end{document}

在此处输入图片描述

相关内容