如何扩展 beamertemplate{background}?

如何扩展 beamertemplate{background}?

我正在编写自定义 Beamer 主题。在我的其中一个主题.sty文件中,我使用:

\setbeamertemplate{background}{
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
    \fill[color=greenCiti] (0,0) rectangle(\the\paperwidth,0.75);
    \node at (0.7,9.2) {\includegraphics{logo-citi-small.png}};
    \node at (1.0,0.375) {\includegraphics[width=1.5cm]{logo-univ.png}};
    \node at (3.5,0.375) {\includegraphics[width=3.2cm]{logo-ra.png}};
    \node at (11.6,0.36) {\includegraphics[width=2.5cm]{logo-insa.png}};
  \end{tikzpicture}
} 

现在我需要扩展此属性,以便在幻灯片的右上角添加第四张图像,但仅限于使用主题的一个文档,因此不在主题文件本身中。

即我想添加第四行,例如:

\node at (6.6,5.2) {\includegraphics[width=2cm]{fig/logo-bull.png}};

我该如何实现这个目标?

答案1

您可以\setbeamertemplate{background}...}在文档本身中使用。这里我使用了背景图片。

\setbeamertemplate{background}{%
    \tikz[remember picture]\node[inner sep=0pt,outer sep=0pt,opacity=0.4] at (current page.center) {\includegraphics[width=\paperwidth,height=\paperheight]{background1}};
}

将上面的内容替换setbeamertemplate为背景的相关代码,并将下面代码中的主题替换为您的主题。

完整代码:

\documentclass[compress]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetheme{Madrid}
\usepackage{tikz}

\title{There Is No Largest Prime Number}
\date[ISPN ’80]{27th International Symposium of Prime Numbers}
\author[Euclid]{Euclid of Alexandria \texttt{[email protected]}}

\setbeamertemplate{background}{%
    \tikz[remember picture]\node[inner sep=0pt,outer sep=0pt,opacity=0.4] at (current page.center) {\includegraphics[width=\paperwidth,height=\paperheight]{background1}};
}

\begin{document}
\begin{frame}
\titlepage
\end{frame}
\section{First section}
\subsection{1}

\begin{frame}
\frametitle{There Is No Largest Prime Number}
\framesubtitle{The proof uses \textit{reductio ad absurdum}.}
\begin{theorem}
There is no largest prime number. \end{theorem}
\end{frame}

\end{document}

在此处输入图片描述

相关内容