如何擴充beamertemplate{background}?

如何擴充beamertemplate{background}?

我正在編寫一個自訂投影機主題。在.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}

在此輸入影像描述

相關內容