tikz:在间谍上方绘制

tikz:在间谍上方绘制

我想在 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}

在此处输入图片描述

相关内容