标题图像未覆盖整个表面

标题图像未覆盖整个表面

我正在尝试创建自己的 Beamer 主题,但有些简单的事情却失败了。不幸的是,我完全搞不懂,希望有人能为我提供解决方案。

正如您从主题中看到的,我想在 beamerinnertheme.sty 中实现标准图像。

到目前为止,我已经成功加载了标准图像。问题是它没有覆盖整个空白区域,而是留下了一大块白条。

我应该在代码中的哪里设置它,以便图像可以覆盖整个表面?我还想注意其中的不同纵横比。

beamerinnertheme.sty:

\documentclass[%
aspectratio=169,%
]{beamer}

\usepackage {mwe}
\usepackage{tikz}
\usepackage{xcolor}

\title{TITLE}
\author{NAME}
\institute{INSTITUT}
\date{DATE}

% Content from the beamertheme.sty

\setbeamertemplate{navigation symbols}{}

% Content from the beamerinnertheme.sty

\setbeamertemplate{background}
{
   \begin{tikzpicture}
       \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
       \fill[color=blue] (0,2) rectangle (\the\paperwidth,\the\paperheight-175);
       \fill[color=green] (0,0) rectangle(2.95,1.9);
       \fill[color=red] (3.05,0) rectangle(\the\paperwidth-100,1.9);
       \node[anchor=south east, inner sep =0pt] at (\the\paperwidth-0.5cm,0.5cm) {\includegraphics[width=2.8cm]{example-image-b}};
       \ifx\inserttitlegraphic\empty%
           \node[anchor=south, inner sep=0pt] at (current page.center) {\includegraphics[width=\paperwidth,height=\paperheight]{example-image-16x9}};
       \fi     
       \ifnum\thepage>1\relax%
           \fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
       \fi     
       
   \end{tikzpicture}
}

\defbeamertemplate*{title page}{test}[1][]
{       
   \vskip6cm%
   \begin{beamercolorbox}[wd=12cm,leftskip=3cm,sep=8pt,#1]{title page header}
       \usebeamerfont{title}\inserttitle\par%
   \end{beamercolorbox}%
   \vskip0.5cm%75
   \begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{author}
       \usebeamerfont{author}\insertauthor%
   \end{beamercolorbox}
   \vskip0.2cm%
   \begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{date}
       \usebeamerfont{author}\insertdate%
   \end{beamercolorbox}
   \vfill
}


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

\end{document}

答案1

通过使用,\node[anchor=south, inner sep=0pt] at (current page.center) {...}您可以将图像的南边放置在页面的中心。这不是您的蓝色条结束的地方。相反,您可以将其放置在蓝色条上方,例如使用\node[anchor=south, inner sep=0pt] at ([yshift=3cm]current page.south) {...}

我不建议同时指定图像的高度和宽度,这在几乎所有情况下都会导致图像扭曲。

事实上,我建议将方框作为标题页的一部分绘制,而不是使用单独的背景。这将使文本更容易在方框中垂直居中:

\documentclass[%
aspectratio=169,%
]{beamer}

\usepackage{mwe}
\usepackage{tikz}
%\usepackage{xcolor}

\title{TITLE}
\author{NAME}
\institute{INSTITUT}
\date{DATE}

% Content from the beamertheme.sty

\setbeamertemplate{navigation symbols}{}

% Content from the beamerinnertheme.sty

\defbeamertemplate*{title page}{test}[1][]
{
   \begin{tikzpicture}[remember picture,overlay]
       \node[fill=blue,minimum height=1cm,text width=\paperwidth] at ([yshift=2.5cm]current page.south) {};
       \node[anchor=west] at ([yshift=2.5cm,xshift=-4.5cm]current page.south) {\usebeamerfont{title}\inserttitle};       
       \fill[color=green] (current page.south west) rectangle ++(2.95,1.9);
       \node[fill=red,minimum height=1.9cm,text width=\paperwidth-6.5cm] at ([yshift=0.95cm]current page.south) {};
       \node[anchor=west,minimum height=1.9cm,text width=\paperwidth-6.5cm] at ([yshift=0.95cm,xshift=-4.5cm]current page.south) {\usebeamerfont{author}\insertauthor\par\vskip0.1cm \usebeamerfont{author}\insertdate};
       \node[anchor=south east, inner sep =0.5cm] at (current page.south east) {\includegraphics[width=2.8cm]{example-image-b}};
       \ifx\inserttitlegraphic\empty%
         \node[anchor=south, inner sep=0pt] at ([yshift=3cm]current page.south) {\includegraphics[width=\paperwidth]{example-image-16x9}};
       \fi     
   \end{tikzpicture}   
}

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

\end{document}

在此处输入图片描述

相关内容