我使用代码
\usebackgroundtemplate{
\centering
\includegraphics[width=0.5\paperwidth,height=0.5\paperheight]{image.png}
}
在 Beamer/Latex 演示文稿中获取背景图像。但是,例如,块不是透明的(它们具有白色背景,因此看不到图像)。标题页上的标题也是如此。
我如何设置块/标题以使其透明?
答案1
您可以使用以下方式指定块的不透明度\addtobeamertemplate
:
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}}
\addtobeamertemplate{block alerted begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}}
\addtobeamertemplate{block example begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}}
但是如果使用块阴影的话效果就不太好。
例子:
\documentclass[compress]{beamer}
\usecolortheme{rose}
\usebackgroundtemplate{\centering
\includegraphics[width=\paperwidth,height=\paperheight]{image.png}}
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}}
\addtobeamertemplate{block alerted begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}}
\addtobeamertemplate{block example begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}}
\begin{document}
\begin{frame}{}
\begin{theorem}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue.
\end{theorem}
\begin{alertblock}{Alert!!!}
Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{alertblock}
\begin{exampleblock}{Example}
Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros.
\end{exampleblock}
\end{frame}
\end{document}
答案2
在 Beamer 中,块和标题默认为透明,因此您必须使用为它们提供背景的主题。您可以使用以下方法恢复默认的透明行为
\setbeamertemplate{title page}[default]
\setbeamercolor{title}{bg=}
标题和
\setbeamertemplate{blocks}[default]
\setbeamercolor{block title}{bg=}
\setbeamercolor{block body}{bg=}
用于块。
以下是完整示例:
\documentclass{beamer}
\usebackgroundtemplate{
\centering\includegraphics[width=\paperwidth,height=\paperheight]{image}
}
\usetheme{Madrid} % Sample theme with coloured title and blocks
% Reset title background to default
\setbeamertemplate{title page}[default]
\setbeamercolor{title}{bg=}
% Reset block background to default
\setbeamertemplate{blocks}[default]
\setbeamercolor{block title}{bg=}
\setbeamercolor{block body}{bg=}
\title{The title}
\begin{document}
\frame{\titlepage}
\begin{frame}{Test frame}
\begin{block}{Block title}
Inside the block
\end{block}
\end{frame}
\end{document}