![使用不透明度时,beamer 和 tikz spy 出现问题](https://linux22.com/image/450848/%E4%BD%BF%E7%94%A8%E4%B8%8D%E9%80%8F%E6%98%8E%E5%BA%A6%E6%97%B6%EF%BC%8Cbeamer%20%E5%92%8C%20tikz%20spy%20%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
我有这个问题。当我使用库时叠加投影仪样式使用间谍和不透明度时,间谍不能很好地工作。
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}