我正在尝试展示一个包含两个成分的方程。对于每个成分,我想逐一解释每个术语,因此能够使用\underbrace
以下方法逐个揭示成分此链接。问题是我无法逐个揭开tikzpicture中对应的情节(它们都在最后出现。
换句话说,第一个图形应该与第一个下划线一起出现,第二个下划线也应如此。这是我对可见性的定义的问题,tiksset
还是根本做不到?
\documentclass[xcolor={dvipsnames,table}, fleqn]{beamer}
\usefonttheme{professionalfonts}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots, backgrounds, plotmarks, calc, spy, pgfplots.polar, shapes.geometric, arrows, external, patterns}
\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt={#1{}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\begin{document}
\begin{frame}
\[ x = \onslide<2-> \underbrace{ \onslide<1-> a \onslide<2-> }_{\text{(A)}} \onslide<1-> - \onslide<3-> \underbrace{ \onslide<1->b \onslide<3-> }_{\text{(B)}} \]
\begin{figure}
\centering
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=1 by 3,
},
unit vector ratio*=1 1 1,
xmin=-1.5,xmax=1.5,
ymin=0,ymax=1.8,
width = 4cm,
axis line style={draw=none},
xmajorticks=false,
ymajorticks=false
]
\nextgroupplot[]
\addplot [visible on=<2->, thick,color=black,mark=none,fill=black,
fill opacity=0.05] coordinates {
(-1.5,0) (-1.5,1.5) (-0.5, 0.5) (0.5, 0.) (1.5, 1.5) (1.5,0) };
\nextgroupplot[]
\addplot [visible on=<3->, thick,color=black,mark=none,fill=black,
fill opacity=0.05] coordinates {
(-1.5,0) (-1.5,1.5) (-0.5,0) (0.5,0) (1.5, 1.5) (1.5,0) };
\nextgroupplot[ymax=1]
\addplot [thick,color=black,mark=none,fill=black,
fill opacity=0.05] coordinates {
(-0.5, 0) (-0.5,0.5) (0.5,0)};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
答案1
问题出在你的\onslide
构造上。你\onslide<3->
在其末尾有一个,以至于后面的所有内容都只出现在幻灯片 3 之后。要解决这个问题,你只需要在\onslide<1->
方程式后面添加一个。我还将填充更改为,black!5
因为你的不透明度指令会覆盖opacity=0
用于使图表在早期幻灯片上不可见的技巧。
\documentclass[xcolor={dvipsnames,table}, fleqn]{beamer}
\usefonttheme{professionalfonts}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots, backgrounds, plotmarks, calc, spy, pgfplots.polar, shapes.geometric, arrows, external, patterns}
\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt={#1{}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\begin{document}
\begin{frame}
\[ x = \onslide<2-> \underbrace{ \onslide<1-> a \onslide<2-> }_{\text{(A)}} \onslide<1-> - \onslide<3-> \underbrace{ \onslide<1->b \onslide<3-> }_{\text{(B)}} \]
\onslide<1->
\begin{figure}
\centering
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=1 by 3,
},
unit vector ratio*=1 1 1,
xmin=-1.5,xmax=1.5,
ymin=0,ymax=1.8,
width = 4cm,
axis line style={draw=none},
xmajorticks=false,
ymajorticks=false
]
\nextgroupplot[]
\addplot [visible on=<2->, thick,color=black,mark=none,fill=black!5] coordinates {
(-1.5,0) (-1.5,1.5) (-0.5, 0.5) (0.5, 0.) (1.5, 1.5) (1.5,0) };
\nextgroupplot[]
\addplot [visible on=<3->, thick,color=black,mark=none,fill=black!5] coordinates {
(-1.5,0) (-1.5,1.5) (-0.5,0) (0.5,0) (1.5, 1.5) (1.5,0) };
\nextgroupplot[ymax=1]
\addplot [thick,color=black,mark=none,fill=black!5] coordinates {
(-0.5, 0) (-0.5,0.5) (0.5,0)};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}