如何使 tcolorbox 内的文本也像覆盖一样透明?

如何使 tcolorbox 内的文本也像覆盖一样透明?

我想在幻灯片顶部的框中放置一些文本,在下一张幻灯片中,此框及其内的文本将变为透明,达到我指定的某种不透明度。tcolorbox 对我来说至关重要,因为我希望框的颜色和形状保持一致。我目前正在尝试 \uncover,但它不会使文本透明。

我还有一个问题,那就是如何确保 tcolorbox 后面没有太多空格?在这个例子中没有显示太多,但我只是想能够控制 tcolorbox 和下一行之间的间距。

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage{tcolorbox}

\usepackage{verbatim}
\usepackage{tikz}
\usepackage{booktabs}
\usetikzlibrary{matrix,overlay-beamer-styles}

\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
%%%%%%%%%
\usetikzlibrary{calc}
\definecolor{pbblue}{HTML}{0A75A8}% color for the progress bar and the circle

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@rcircle % radius for the circle
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1pt
\progressbar@rcircle=2.5pt

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}
    \draw[pbblue!30,line width=\progressbar@pbht]
      (0pt, 0pt) -- ++ (\progressbar@pbwd,0pt);

    \filldraw[pbblue!30] %
      (\the\dimexpr\progressbar@tmpdim-\progressbar@rcircle\relax, .5\progressbar@pbht) circle (\progressbar@rcircle);

    \node[draw=pbblue!30,text width=3.5em,align=center,inner sep=1pt,
      text=pbblue!70,anchor=east] at (0,0) {\insertframenumber/\inserttotalframenumber};
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother
%%%%%%%%%%%
\begin{document}
\section{Proofs}
\begin{frame}[t]{title }
\setbeamercovered{transparent}%

\uncover<1>{\begin{tcolorbox}[hbox, left = 0.1 mm, right=0.1 mm, top = 0.4mm, bottom = 0.4mm]
Main idea
\end{tcolorbox}}

\uncover<2>{asdfasdf}
\end{frame}


\end{document}

答案1

tcolorbox提供了很多beamer支持,请参阅13 Beamer 支持手册 v4.30。在粒子中,有一个hide键,可以在这里使用。然后可以使用

\tcbset{beamer hidden/.style={}}

这是一个例子。

\documentclass{beamer}
\mode<presentation>
{
%  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
%  \usecolortheme{default} % or try albatross, beaver, crane, ...
%  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage[skins]{tcolorbox}

\usepackage{verbatim}
\usepackage{tikz}
\usepackage{booktabs}
\usetikzlibrary{matrix,overlay-beamer-styles}

\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
%%%%%%%%%
\usetikzlibrary{calc}
\definecolor{pbblue}{HTML}{0A75A8}% color for the progress bar and the circle

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@rcircle % radius for the circle
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1pt
\progressbar@rcircle=2.5pt

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}
    \draw[pbblue!30,line width=\progressbar@pbht]
      (0pt, 0pt) -- ++ (\progressbar@pbwd,0pt);

    \filldraw[pbblue!30] %
      (\the\dimexpr\progressbar@tmpdim-\progressbar@rcircle\relax, .5\progressbar@pbht) circle (\progressbar@rcircle);

    \node[draw=pbblue!30,text width=3.5em,align=center,inner sep=1pt,
      text=pbblue!70,anchor=east] at (0,0) {\insertframenumber/\inserttotalframenumber};
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=4ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother
%%%%%%%%%%%
\tcbset{
beamer hidden/.style={opacityframe=0.1,opacityback=0.1,
opacitybacktitle=0.1,opacitytext=0.1}, }
\begin{document}
\section{Proofs}
\begin{frame}[t]{title }
\setbeamercovered{transparent}%

\begin{tcolorbox}[hbox, left = 0.1 mm, right=0.1 mm, 
top = 0.4mm, bottom = 0.4mm,hide=<2->]
Main idea
\end{tcolorbox}

\uncover<2>{asdfasdf}
\end{frame}
\end{document}

在此处输入图片描述

还有更多选择可以实现类似的结果。

附录:对于评论中的问题,您可以使用overprint环境。

\documentclass{beamer}
\setbeamercovered{transparent}%
\begin{document}
\begin{frame}[t]
\frametitle{Without overprint}
\onslide<1>
Einstein said that \[E=mc^2\]
\onslide<2>
test

abc
\end{frame}

\begin{frame}[t]
\frametitle{With overprint}
\begin{overprint}
\onslide<1>
Einstein said that \[E=mc^2\]
\onslide<2>
test
\end{overprint}

abc
\end{frame}
\end{document}

在此处输入图片描述

相关内容