我有这个问题。当我使用库时叠加投影仪样式使用间谍和不透明度时,间谍不能很好地工作。
visible on=<>
当我使用两个不同的\spy
并引入opacity
图像时,问题就开始了。这是代码:
\documentclass[compress]{beamer}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc, spy, overlay-beamer-styles, backgrounds}
\begin{document}
\begin{frame}
\centering
\begin{tikzpicture}[spy using overlays,
spy using outlines={circle,
size=1cm,
connect spies}
]
\pgfmathsetseed{10}
\newcommand{\Xa}{1.75}
\newcommand{\Ya}{2}
\newcommand{\Ca}{.9}
\node (a) at (\Xa,\Ya) {};
\foreach \p in {1,...,100}{
\pgfmathsetmacro{\xx}{\Ca*rand}
\coordinate (pta) at (1.5*\xx+\Xa,{rand*sqrt(\Ca^2-(\xx)^2)+\Ya});
\fill[opacity=.2, visible on=<1>] (pta) circle (0.04);
}
\spy[magnification=1.5, visible on=<1>] on (a) in node at (2.5,5);
\spy[magnification=2.5, visible on=<2>] on (1.5,1.5) in node at (2.5,5);
\end{tikzpicture}
\end{frame}
\end{document}
即使没有点,第二个\spy
覆盖也只取opacity
。\fill
我还有另一个例子:
第二个的某些部分在前一个中\spy
显示。opacity
\spy
答案1
您可以通过\only<>{...}
确保每个间谍只在一张幻灯片上来避免这个问题:
\documentclass[compress]{beamer}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc, spy, overlay-beamer-styles, backgrounds}
\begin{document}
\begin{frame}
\centering
\begin{tikzpicture}[spy using overlays,
spy using outlines={circle,
size=1cm,
connect spies}
]
\pgfmathsetseed{10}
\newcommand{\Xa}{1.75}
\newcommand{\Ya}{2}
\newcommand{\Ca}{.9}
\node (a) at (\Xa,\Ya) {};
\foreach \p in {1,...,100}{
\pgfmathsetmacro{\xx}{\Ca*rand}
\coordinate (pta) at (1.5*\xx+\Xa,{rand*sqrt(\Ca^2-(\xx)^2)+\Ya});
\fill[opacity=.2] (pta) circle (0.04);
}
\only<1>{\spy[magnification=1.5] on (a) in node at (2.5,5);}
\only<2>{\spy[magnification=2.5, visible on=<2>] on (1.5,1.5) in node at (2.5,5);}
\end{tikzpicture}
\end{frame}
\end{document}