我有一张幻灯片,其中有一个节点矩阵,每次只显示一个节点。每个节点都有多行文本和数学运算(下面显示的示例代码删除了一些数学运算,以抽象出细节)。我希望在其中一个节点出现后突出显示它,方法是以某种方式自定义其外观(例如,更改框架颜色或背景颜色等)。具体来说,在下面的示例中,我想在第六张幻灯片之后更改最右下角节点(其中包含“stuff 4”的节点)的这些功能。
\documentclass{beamer}
\mode<presentation>
{
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}
%%%%%%%%%
\usetikzlibrary{calc}
%%%%%%%%
\tcbuselibrary{theorems}
\newtcbtheorem[]{mylemmma}{Lemma}{colframe=green,colback=white, width=\textwidth}{lem}
\tcbset{colframe=green, colback=white}
\resetcounteronoverlays{tcb@cnt@mylemmma}
\begin{document}
\section{Proofs}
\newtcbtheorem[]{mydef}{Problem Statement}{colframe=white, colback=white}{ps}
\tcbset{colframe=black, colback=white}
\resetcounteronoverlays{tcb@cnt@mydef}
\begin{frame}[fragile]
\centering
\begin{tikzpicture}[optimization problem/.style = {%
rounded corners,
draw = green,
thick,
fill = white,
inner ysep = 5pt,
inner xsep = 1pt,
align = center},
myplainbox/.style = {%
rounded corners,
draw = green,
thick,
fill= white,
inner ysep=5pt,
inner xsep=1pt,
align = center},
]
\matrix[matrix of nodes,row sep=1em,column sep=1.6em,
nodes={anchor=west,
visible on=<\the\numexpr\pgfmatrixcurrentcolumn+2*\pgfmatrixcurrentrow-2\relax->,},
row 1/.style={nodes={optimization problem,
text width=12.8em,
text depth = 3.5 em,
text height = 1 em,
}},
column 1/.style={nodes={myplainbox,
text width=12.8em,
% text depth = 3.5 em,
% text height = 1 em,
}},
column 2/.style={nodes={myplainbox,
text width=12.8em,
% text depth = 3.5 em,
% text height = 1 em,
}},
](M){
{some words here\\ $\scriptstyle f(x) - g(x)$ \\ $\scriptstyle \leq p(x) + q(x) + r(x)$.} & {some words here\\ $\scriptstyle f(x) - g(x)$ \\ $\scriptstyle \leq p(x) + q(x) + r(x)$.}\\
{stuff \\ more stuff} & {stuff 2 \\ more stuff 2}\\
{stuff \\ more stuff} & {stuff 4 \\ more stuff 4}\\
};
\draw[->, thick, visible on = <2->] (M-1-1)--(M-1-2) node[midway, above] {\checkmark};
\end{tikzpicture}
\end{frame}
\end{document}
答案1
这很简单:向相应的矩阵元素添加一些本地键。如 pgfmanual v3.1.5 第 710 页所述,通过|[<style>]|
向矩阵元素添加一些适当的样式,即可实现此目的。我刚刚添加了
|[alt=<7>{draw=red,thick,fill=red!20}{}]|
要得到
\documentclass{beamer}
\mode<presentation>
{
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{matrix,overlay-beamer-styles}
%%%%%%%%%
\usetikzlibrary{calc}
%%%%%%%%
\tcbuselibrary{theorems}
\newtcbtheorem[]{mylemmma}{Lemma}{colframe=green,colback=white, width=\textwidth}{lem}
\tcbset{colframe=green, colback=white}
\resetcounteronoverlays{tcb@cnt@mylemmma}
\begin{document}
\section{Proofs}
\newtcbtheorem[]{mydef}{Problem Statement}{colframe=white, colback=white}{ps}
\tcbset{colframe=black, colback=white}
\resetcounteronoverlays{tcb@cnt@mydef}
\begin{frame}[fragile]
\centering
\begin{tikzpicture}[optimization problem/.style = {%
rounded corners,
draw = green,
thick,
fill = white,
inner ysep = 5pt,
inner xsep = 1pt,
align = center},
myplainbox/.style = {%
rounded corners,
draw = green,
thick,
fill= white,
inner ysep=5pt,
inner xsep=1pt,
align = center},
]
\matrix[matrix of nodes,row sep=1em,column sep=1.6em,
nodes={anchor=west,
visible on=<\the\numexpr\pgfmatrixcurrentcolumn+2*\pgfmatrixcurrentrow-2\relax->,},
row 1/.style={nodes={optimization problem,
text width=12.8em,
text depth = 3.5 em,
text height = 1 em,
}},
column 1/.style={nodes={myplainbox,
text width=12.8em,
% text depth = 3.5 em,
% text height = 1 em,
}},
column 2/.style={nodes={myplainbox,
text width=12.8em,
% text depth = 3.5 em,
% text height = 1 em,
}},
](M){
{some words here\\ $\scriptstyle f(x) - g(x)$ \\ $\scriptstyle \leq p(x) + q(x) + r(x)$.} & {some words here\\ $\scriptstyle f(x) - g(x)$ \\ $\scriptstyle \leq p(x) + q(x) + r(x)$.}\\
{stuff \\ more stuff} & {stuff 2 \\ more stuff 2}\\
{stuff \\ more stuff} & |[alt=<7>{draw=red,thick,fill=red!20}{}]|{stuff 4 \\ more stuff 4}\\
};
\draw[->, thick, visible on = <2->] (M-1-1)--(M-1-2) node[midway, above] {\checkmark};
\end{tikzpicture}
\end{frame}
\end{document}