这是一个后续问题如何制作部分透明的 beamercolorbox
问题是我想要一个透明的 beamercolorbox,但文本不透明。我该怎么办?我也不喜欢 beamercolorbox 顶部的深色线条。我也愿意接受其他可能性。以下是有问题的幻灯片的一个最小示例:
\documentclass[xcolor=usenames,dvipsnames]{beamer}
\colorlet{color1}{PineGreen}
\mode<presentation>
{
\usetheme{default}
\usecolortheme{lily}
\usefonttheme{professionalfonts}
\setbeamercolor{alert}{fg=red!80!black}
\setbeamercolor{text1}{fg=color1!80!black}
\setbeamercolor{text2}{fg=black}
\setbeamercolor{structure}{fg=color1!80!black}
\setbeamercolor{frametitle}{fg=red!80!black}
\setbeamercolor{box1}{fg=black,bg=Dandelion}
\setbeamercolor{box2}{fg=black,bg=SeaGreen}
\setbeamercolor{box3}{fg=black,bg=Aquamarine}
\setbeamerfont{frametitle}{series=\bfseries}
\setbeamertemplate{frametitle}
{
\begin{flushright}
\insertframetitle\par
\end{flushright}
}
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{figures/PNG/ripple.png}}
\setbeamercovered{transparent}
\setbeamerfont{title}{size=\Large,series=\bfseries,shape=\itshape,family= \rmfamily}
\setbeamercolor{title}{fg=red!80!black}
}
\usepackage[english]{babel}
\usepackage{aas_macros}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\begin{document}
\begin{frame}
\frametitle{slide title}
\pgfsetfillopacity{0.35}
\begin{columns}
\column{0.5\textwidth}
\pgfsetfillopacity{0.35}
\begin{beamercolorbox}[shadow=false,rounded=true]{box2}
{\usebeamercolor[fg]{text2} \bf T1}
\begin{itemize}
\item element
\item element
\item element
\item element
\item element
\end{itemize}
\end{beamercolorbox}
\column{0.5\textwidth}
\begin{beamercolorbox}[shadow=false,rounded=true]{box3}
{\usebeamercolor[fg]{text2} \bf T2}
\begin{itemize}
\item element
\item element
\item element
\item element
\end{itemize}
\end{beamercolorbox}
\end{columns}
\begin{beamercolorbox}[shadow=false,rounded=true]{box1}
\begin{itemize}
\item element
\item element
\end{itemize}
\end{beamercolorbox}
\end{frame}
\end{document}
答案1
考虑到颜色框的构建方式,目前我发现的唯一方法是重新定义\beamerboxesrounded
,如在中实现的,并beamerbaseboxes.sty
使用\pgfsetfillopacity
控制所需的值\opacitylevel
;下面的代码显示了这种重新定义(有变化的行用信号表示%NEW
):
\documentclass[xcolor=usenames,dvipsnames]{beamer}
\colorlet{color1}{PineGreen}
\mode<presentation>
{
\usetheme{default}
\usecolortheme{lily}
\usefonttheme{professionalfonts}
\setbeamercolor{alert}{fg=red!80!black}
\setbeamercolor{text1}{fg=color1!80!black}
\setbeamercolor{text2}{fg=black}
\setbeamercolor{structure}{fg=color1!80!black}
\setbeamercolor{frametitle}{fg=red!80!black}
\setbeamercolor{box1}{fg=black,bg=Dandelion}
\setbeamercolor{box2}{fg=black,bg=SeaGreen}
\setbeamercolor{box3}{fg=black,bg=Aquamarine}
\setbeamerfont{frametitle}{series=\bfseries}
\setbeamertemplate{frametitle}
{
\begin{flushright}
\insertframetitle\par
\end{flushright}
}
\usebackgroundtemplate{\includegraphics[width=\paperwidth,height=\paperheight]{b}}
\setbeamercovered{transparent}
\setbeamerfont{title}{size=\Large,series=\bfseries,shape=\itshape,family= \rmfamily}
\setbeamercolor{title}{fg=red!80!black}
}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\newcommand\opacitylevel{0.35}% change here the opacity level
\makeatletter
\renewcommand\beamerboxesrounded[2][]{%
\global\let\beamer@firstlineitemizeunskip=\relax%
\vbox\bgroup%
\setkeys{beamerboxes}{upper=block title,lower=block body,width=\textwidth,shadow=false}%
\setkeys{beamerboxes}{#1}%
{%
\usebeamercolor{\bmb@lower}%
\globalcolorstrue%
\colorlet{lower.bg}{bg}%
}%
{%
\usebeamercolor{\bmb@upper}%
\globalcolorstrue%
\colorlet{upper.bg}{bg}%
}%
%
% Typeset head
%
\vskip4bp
\setbox\bmb@box=\hbox{%
\begin{minipage}[b]{\bmb@width}%
\usebeamercolor[fg]{\bmb@upper}%
#2%
\end{minipage}}%
\ifdim\wd\bmb@box=0pt%
\setbox\bmb@box=\hbox{}%
\ht\bmb@box=1.5pt%
\bmb@prevheight=-4.5pt%
\else%
\wd\bmb@box=\bmb@width%
\bmb@temp=\dp\bmb@box%
\ifdim\bmb@temp<1.5pt%
\bmb@temp=1.5pt%
\fi%
\setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
\dp\bmb@box=0pt%
\bmb@prevheight=\ht\bmb@box%
\fi%
\bmb@temp=\bmb@width%
\bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
\bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
\hbox{%
\begin{pgfpicture}{0bp}{+-\ht\bmb@box}{0bp}{+-\ht\bmb@box}
\ifdim\wd\bmb@box=0pt%
\color{lower.bg}%
\else%
\color{upper.bg}%
\fi%
\pgfsetfillopacity{\opacitylevel}%NEW
\pgfpathqmoveto{-4bp}{-1bp}
\pgfpathqcurveto{-4bp}{1.2bp}{-2.2bp}{3bp}{0bp}{3bp}
\pgfpathlineto{\pgfpoint{\bmb@temp}{3bp}}
\pgfpathcurveto%
{\pgfpoint{\bmb@dima}{3bp}}%
{\pgfpoint{\bmb@dimb}{1.2bp}}%
{\pgfpoint{\bmb@dimb}{-1bp}}%
\bmb@dima=-\ht\bmb@box%
\advance\bmb@dima by1pt%NEW
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}}
\pgfusepath{fill}
\end{pgfpicture}%
\copy\bmb@box%
}%
\nointerlineskip%
\vskip-1pt%
\ifdim\wd\bmb@box=0pt%
\else%
\hbox{%
\begin{pgfpicture}{0pt}{0pt}{\bmb@width}{6pt}
\bmb@dima=\bmb@width%
\advance\bmb@dima by8bp%
\pgfpathrectangle{\pgfpoint{-4bp}{-1bp}}{\pgfpoint{\bmb@dima}{8bp}}
\pgfusepath{clip}
{\pgftransformshift{\pgfpoint{-4bp}{0bp}}\pgftext[left,base]{\pgfuseshading{bmb@transition}}}%
\end{pgfpicture}%
}%
\nointerlineskip%
\vskip-0.5pt%
\fi%
\ifbmb@shadow%
\setbox\bmb@boxshadow=\hbox{\pgfuseshading{bmb@shadow}}%
\setbox\bmb@boxshadowball=\hbox{\pgfuseshading{bmb@shadowball}}%
\setbox\bmb@boxshadowballlarge=\hbox{\pgfuseshading{bmb@shadowballlarge}}%
\fi%
\setbox\bmb@colorbox=\hbox{{\pgfpicturetrue\pgfsetfillopacity{\opacitylevel}\pgfsetcolor{lower.bg}}}%NEW
\setbox\bmb@box=\hbox\bgroup\begin{minipage}[b]{\bmb@width}%
\vskip2pt%
\usebeamercolor[fg]{\bmb@lower}%
\colorlet{beamerstructure}{upper.bg}%
\colorlet{structure}{upper.bg}%
%\color{.}%
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{slide title}
\begin{columns}
\column{0.5\textwidth}
\begin{beamercolorbox}[shadow=false,rounded=true]{box2}
{\usebeamercolor[fg]{text2} \bf T1}
\begin{itemize}
\item element
\item element
\item element
\item element
\item element
\end{itemize}
\end{beamercolorbox}
\column{0.5\textwidth}
\begin{beamercolorbox}[shadow=false,rounded=true]{box3}
{\usebeamercolor[fg]{text2} \bf T2}
\begin{itemize}
\item element
\item element
\item element
\item element
\end{itemize}
\end{beamercolorbox}
\end{columns}
\begin{beamercolorbox}[shadow=false,rounded=true]{box1}
\begin{itemize}
\item element
\item element
\end{itemize}
\end{beamercolorbox}
\end{frame}
\end{document}
作为background
模板,我使用了 Duane Bibby 的 CTAN 狮子。
答案2
您可以使用tcolorbox
内部 beamer 主题。这样您就可以用 替换正常的beamercolorboxe
,tcolorboxes
并且可以轻松调整背景不透明度:
\documentclass[xcolor={dvipsnames}]{beamer}
\setbeamercolor{text2}{fg=black}
\setbeamercolor{box2}{fg=black,bg=SeaGreen}
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{example-grid-100x100bp}}
\useinnertheme[rounded]{tcolorbox}
\makeatletter
\beamer@tcb@patchcolorbox
\makeatother
\tcbset{
opacityback=0.6,
}
\begin{document}
\begin{frame}
\begin{beamercolorbox}[shadow=false,rounded=true]{box2}
{\usebeamercolor[fg]{text2} \bfseries Title}
content
\end{beamercolorbox}
\end{frame}
\end{document}