我想在 tikz-spy 上畫畫,新行應該是覆蓋那些被間諜複製的。例如:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{spy,shapes}
\pgfdeclarelayer{bg} % declare background layer
\pgfsetlayers{bg,main} % set the order of the layers (main is the standard layer)
\begin{document}
\begin{tikzpicture}[spy using outlines={rectangle, width=4.5cm, height=3cm, magnification=4, connect spies,every spy on node/.append style={thin}},hide/.style={opacity=1}]
\begin{scope}
\draw circle (8) node[yshift=8.8cm,align=center] {};
\draw circle (8.2) node {};
\draw (-5,7.4) -- (5,7.4);
\end{scope}
%\begin{pgfonlayer}{bg} % select the background layer
\spy [black] on (-3.4,7.4) in node (spyleft) [left] at (-0.5,4.5);
%\end{pgfonlayer}
%\begin{pgfonlayer}{main} % select the main layer
\draw[line width=2pt,color=blue] (-3.3,4.5) -- (-1.35,4.5) -- (-1.35,5.35) -- cycle;
%\end{pgfonlayer}
\end{tikzpicture}
\end{document}
黑色線條上方應有藍色三角形。明確地將繪圖的各個部分放入圖層中似乎沒有幫助。是否有我可以解決的特定間諜層?
(理想情況下,我還希望三角形的角由圓和線的交點來定義,但現在我很樂意手動定位它,只要我能得到正確的圖層...)
答案1
聲明一個前景圖層並將藍色三角形放在該圖層上。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{spy,shapes}
\pgfdeclarelayer{fg} % declare foreground layer
\pgfsetlayers{main,fg} % set the order of the layers (main is the standard layer)
\begin{document}
\begin{tikzpicture}[spy using outlines={rectangle, width=4.5cm, height=3cm, magnification=4, connect spies,every spy on node/.append style={thin}},hide/.style={opacity=1}]
\begin{scope}
\draw circle (8) node[yshift=8.8cm,align=center] {};
\draw circle (8.2) node {};
\draw (-5,7.4) -- (5,7.4);
\end{scope}
\spy [black] on (-3.4,7.4) in node (spyleft) [left] at (-0.5,4.5);
\begin{pgfonlayer}{fg} % select the main layer
\draw[line width=2pt,blue] (-3.3,4.5) -- (-1.35,4.5) -- (-1.35,5.35) -- cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{document}