1

This is a variation of the same MWE of this other question:

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{calc}
\usetikzlibrary{spy}
\usetikzlibrary{backgrounds}

\begin{document}

\begin{tikzpicture}
  [spy using outlines={circle, magnification=7, size=3cm, connect spies}]

  \draw[->, very thick] (0,0) -- (5,0);
  \path (2,2) node[fill, rectangle, inner sep=2pt, minimum height=1cm] (n) {};

  \begin{scope}[on background layer]
    \draw[dotted] (n.south west) -- (n.south west |- 0,0);
    \draw[dotted] (n.south east) -- (n.south east |- 0,0);
  \end{scope}

  \spy on ($(n.south east |- 0,0)!0.5!(n.south west |- 0,0)$) 
    in node at (3,-2);
\end{tikzpicture}

\end{document}

This is the output:

mwe

As you can see, the dotted lines are missing from the spy in node. It seems that the spy library ignores the background layer.

Is there a way to make the contents of the background layer appear in the spy in node?

0 Answers0