使用 spy 库,我想首先突出显示(在本例中用矩形)放大的区域,然后在下一张幻灯片中显示放大率。我在下面的 MWE 中手动执行此操作,但更喜欢自动解决方案。
\documentclass[10pt,aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{spy}
\begin{document}
\begin{frame}
\begin{tikzpicture}[%
spy using outlines={rectangle, magnification=4, size=2cm, connect spies},
]
\fill [blue!20] (0,0) rectangle (2,3);
% I want to avoid to manually draw this rectangle:
\draw (-2.5mm,-2.5mm) rectangle (2.5mm, 2.5mm);
\pause
\spy on (0,0) in node at (-2,1);
\end{tikzpicture}
\end{frame}
\end{document}
答案1
非常感谢@samcarter 向我解释这个问题!使用了一些技巧aobs 包。
\documentclass[10pt,aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{spy}
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt={#1{}{invisible}}},
connect on/.style={alt={#1{connect spies}{}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
},
}
\begin{document}
\begin{frame}
\begin{tikzpicture}[%
spy using outlines={rectangle, magnification=4, size=2cm},
]
\fill [blue!20] (0,0) rectangle (2,3);
\spy[connect on=<2->] on (0,0) in node[visible on=<2->] at (-2,1);
\end{tikzpicture}
\end{frame}
\end{document}