我有一张幻灯片,node
上面有三个元素,每个元素上都写了一些数学公式。我想通过以下方式控制它们的可见性和透明度。第一张幻灯片完全显示顶部节点,第二张幻灯片使其透明,第三张幻灯片显示其正下方的节点(保持顶部节点仍然透明......),第四张幻灯片使此节点透明,下一张幻灯片显示最后一个节点,下一张幻灯片再次完全显示顶部节点。虽然节点是透明的,但我希望数学公式也变得透明。我无法让任何类型的透明度“按顺序”工作。
\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[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta,
backgrounds,
calc,
decorations.pathmorphing,
patterns, positioning,
quotes,
shapes,
tikzmark
}
\usetikzlibrary{overlay-beamer-styles}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
%\usepackage{fourier,erewhon}
%\usepackage{amssymb, amsbsy}
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
%\usepackage[x11names, table]{xcolor}
\usepackage{caption}
\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
\begin{document}
\section{Problem Setup, History, \& Our Result: A Snapshot}
\begin{frame}[t]{Applications: An Example}
\begin{tikzpicture}[remember picture,
optimization problem/.style = {%
rounded corners,
draw = myblue,
fill= myyellow,
inner ysep=2pt,
inner xsep=1pt,
align = center
}
]
\draw node[below right=1 cm and 0.3cm of current page.north west, style=optimization problem] (prob)
{
$
\begin{array}{ll}
\textup{minimize} & \mu \\
\textup{subject to} & F(\mu) = 0.
\end{array}
$
};
\draw node [below right= 3.5 cm and .3 cm of current page.north west, align=center, style=optimization problem, visible on = <3->] (mcP)
{
\begin{minipage}{.45\textwidth}
problem description\\
$
\begin{array}{ll}
\textup{maximize} & y \\
\textup{subject to} & g(y)\geq 0.
\end{array}
$
\end{minipage}
};
\draw node [right= 1.2cm of mcP, align=center, style=optimization problem, visible on = <4->] (mcD)
{
\begin{minipage}{0.45\textwidth}
problem description - 2\\
$
\begin{array}{ll}
\textup{minimize} & x \\
\textup{subject to} & f(x)<= 0.
\end{array}
$
\end{minipage}
};
\draw [<->, visible on = <4->] (mcP)--(mcD);
\draw[thick,->,shorten >=1pt, visible on = <5->] (mcD) to [out=90,in=0,loop,looseness=1] (prob);
\end{tikzpicture}
\end{frame}
\end{document}
答案1
让我们首先回顾一下它visible on
的工作原理。它的定义可以在库中找到overlay-beamer-styles
,内容如下
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
}
因此,我们可以通过以下方式定义其类似物
\tikzset{sort of visible/.style={opacity=0.3,text opacity=0.3},
fully visible on/.style={alt=#1{}{sort of visible}}}
可以用作
\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[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta,
backgrounds,
calc,
decorations.pathmorphing,
patterns, positioning,
quotes,
shapes,
tikzmark
}
\usetikzlibrary{overlay-beamer-styles}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
%\usepackage{fourier,erewhon}
%\usepackage{amssymb, amsbsy}
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
%\usepackage[x11names, table]{xcolor}
\usepackage{caption}
\definecolor{myorange}{rgb}{.98, .59, .01}
\definecolor{myyellow}{rgb}{1, .78, .33}
\definecolor{myblue}{rgb}{.18, .63, .78}
% modifications of
% \tikzset{
% invisible/.style={opacity=0,text opacity=0},
% visible on/.style={alt=#1{}{invisible}},
% }
% from overlay-beamer-styles
\tikzset{sort of visible/.style={opacity=0.3,text opacity=0.3},
fully visible on/.style={alt=#1{}{sort of visible}},}
\begin{document}
\section{Problem Setup, History, \& Our Result: A Snapshot}
\begin{frame}[t]{Applications: An Example}
\begin{tikzpicture}[remember picture,overlay,
optimization problem/.style = {%
rounded corners,
draw = myblue,
fill= myyellow,
inner ysep=2pt,
inner xsep=1pt,
align = center
}
]
\draw node[below right=1.5 cm and 1cm of current page.north west,
fully visible on=<{1,5}>,
style=optimization problem] (prob)
{
$
\begin{array}{ll}
\textup{minimize} & \mu \\
\textup{subject to} & F(\mu) = 0.
\end{array}
$
};
\draw node [below right= 4 cm and 1 cm of current page.north west,
align=center, style=optimization problem,
text width=.42\textwidth,
fully visible on = <3->] (mcP)
{%
%\begin{minipage}{.45\textwidth}
problem description\\
$
\begin{array}{ll}
\textup{maximize} & y \\
\textup{subject to} & g(y)\geq 0.
\end{array}
$
% \end{minipage}
};
\draw node [right= 1.2cm of mcP, align=center,
style=optimization problem,
text width=.42\textwidth,
fully visible on = <4->] (mcD)
{%
%\begin{minipage}{0.45\textwidth}
problem description - 2\\
$
\begin{array}{ll}
\textup{minimize} & x \\
\textup{subject to} & f(x)<= 0.
\end{array}
$
%\end{minipage}
};
\draw [<->, visible on = <4->] (mcP)--(mcD);
\draw[thick,->,shorten >=1pt, visible on = <5->] (mcD) to [out=90,in=0,loop,looseness=1] (prob);
\end{tikzpicture}
\end{frame}
\end{document}
给予
请注意,我还做了一些与主题无关的更改。例如,sminipage
可以换成text width
,并且您还需要overlay
使用锚点,例如,current page.north west
而无需被要求无限频繁地重新编译。