如何制作部分透明的 beamercolorbox

如何制作部分透明的 beamercolorbox

在我的海报中,我添加了背景图片,并使用以下代码使块部分透明

\documentclass[final, 12pt]{beamer}
\usepackage[size=custom,width=120,height=120,scale=1.7,orientation=portrait]{beamerposter} 
\usepackage{ragged2e}
\usepackage{graphicx} 
\usepackage{lipsum} 
\usepackage{etoolbox}
\apptocmd{\frame}{\justifying}{}{}

\usebackgroundtemplate{\centering \includegraphics[width=\paperwidth, height=\paperheight]{Figure/LG_PKL.jpg}}
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.65}}{\pgfsetfillopacity{1}}
\addtobeamertemplate{block beamercolorbox begin}{\pgfsetfillopacity{0.65}}{\pgfsetfillopacity{1}}

\newenvironment<>{varblock}[2][\textwidth]{%
  \setlength{\textwidth}{#1}
  \begin{actionenv}#3%
    \def\insertblocktitle{#2}%
    \par%
    \usebeamertemplate{block begin}}
  {\par%
    \usebeamertemplate{block end}%
  \end{actionenv}}

\usecolortheme{rose}


\begin{document}
\begin{frame}

\begin{textblock}{}(0.55,0.05)
\begin{center}
\setlength{\textwidth}{113cm}
\begin{beamercolorbox}{block body}
gdsghfdhdfgh
\end{center}
\end{beamercolorbox}
\end{center}
\end{textblock}


\begin{textblock}{}(0.2,1.15)%
\begin{varblock}[35cm]{\textbf{1. Introduction}}
\justifying 
Space for discussion.
\end{varblock}
\end{textblock}

\end{document}

它与块配合得很好,但我需要使 beamercolorbox 也部分透明。有人能帮帮我吗?

答案1

您的示例代码有一些错误,无法工作。但是,我可以通过对您的示例代码进行简单的修改来重现您的问题(我更改了一些设置以使我的示例更简单,但这与问题或解决方案无关):

\documentclass[final, 12pt]{beamer}
\usepackage[size=custom,width=10,height=10,scale=.7,orientation=portrait]{beamerposter} 
\usepackage{graphicx} 
\usepackage{textpos} 

\usecolortheme{rose}

\usebackgroundtemplate{%
  \centering\includegraphics[width=\paperwidth, height=\paperheight]{ctanlion}}
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.65}}{\pgfsetfillopacity{1}}

\newenvironment<>{varblock}[2][\textwidth]{%
  \setlength{\textwidth}{#1}
  \begin{actionenv}#3%
    \def\insertblocktitle{#2}%
    \par%
    \usebeamertemplate{block begin}}
  {\par%
    \usebeamertemplate{block end}%
  \end{actionenv}}

\begin{document}

\begin{frame}
\begin{textblock}{}(0.55,0.05)
\setlength\textwidth{5cm}
\begin{beamercolorbox}[wd=5cm]{block body}
some test text\\
some test text
\end{beamercolorbox}
\end{textblock}

\vfill

\begin{textblock}{}(0.2,1.15)%
\begin{varblock}[5cm]{Introduction}
Space for discussion.
\end{varblock}
\end{textblock}
\end{frame}

\end{document}

结果表明beamercolobox颜色隐藏了背景图像:

在此处输入图片描述

为了防止出现此问题,您可以简单地在环境\pgfsetfillopacity{0.65}内部使用frame(或者textblock如果您想将更改保持在本地,则在包含有问题的框的环境内部使用):

\documentclass[final, 12pt]{beamer}
\usepackage[size=custom,width=10,height=10,scale=.7,orientation=portrait]{beamerposter} 
\usepackage{graphicx} 
\usepackage{textpos} 

\usecolortheme{rose}

\usebackgroundtemplate{%
  \centering\includegraphics[width=\paperwidth, height=\paperheight]{ctanlion}}
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.65}}{\pgfsetfillopacity{1}}

\newenvironment<>{varblock}[2][\textwidth]{%
  \setlength{\textwidth}{#1}
  \begin{actionenv}#3%
    \def\insertblocktitle{#2}%
    \par%
    \usebeamertemplate{block begin}}
  {\par%
    \usebeamertemplate{block end}%
  \end{actionenv}}

\begin{document}

\begin{frame}
\pgfsetfillopacity{0.65}

\begin{textblock}{}(0.55,0.05)
\setlength\textwidth{5cm}
\begin{beamercolorbox}[wd=5cm]{block body}
some test text\\
some test text
\end{beamercolorbox}
\end{textblock}

\vfill

\begin{textblock}{}(0.2,1.15)%
\begin{varblock}[5cm]{Introduction}
Space for discussion.
\end{varblock}
\end{textblock}
\end{frame}

\end{document}

在此处输入图片描述

CTAN 狮子绘画由 Duane Bibby 绘制。

答案2

您可以使用tcolorbox内部主题。这将用 s 替换普通的 beamer 块tcolorbox,并且还允许您替换默认的beamercolorbox

一旦它们都基于tcolorboxs,就很容易调整背景不透明度:

\documentclass{beamer}

\usebackgroundtemplate{\centering \includegraphics[width=\paperwidth, height=\paperheight]{example-grid-100x100bp}}
\usecolortheme{rose}

\useinnertheme{tcolorbox}
\makeatletter
\beamer@tcb@patchcolorbox
\makeatother
\tcbset{
  opacityback=0.6, 
  opacitybacktitle=0.6
}

\begin{document}
\begin{frame}

\begin{beamercolorbox}{block body}
gdsghfdhdfgh
\end{beamercolorbox}

\begin{block}{1. Introductio}
Space for discussion.
\end{block}
\end{frame}

\end{document}

在此处输入图片描述

相关内容