# TikZ spy library resets line properties, e.g. line join, line width, etc

When using the TikZ spy library in a tikzpicture it “forgets” the line properties, e.g. line join, set previously.

I have looked into the spy library code (at pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex) and noted these lines:

\tikzset{
tikz@lib@reset@gs/.style={black,thin,solid,opaque,line cap=butt,line join=miter}
}


A first quick fix was to use

\tikzset{
spy scope/.append style={
line width=5pt,
line join=round,
},
}


which fixes it for all the image parts that are not magnified, but the lines in the magnified part are still drawn with properties reset.

Setting the property directly to the drawn path preserves it for both parts of the picture.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{spy}

\tikzset{
thick round path/.append style={
line width=5pt,
line join=round,
},
every picture/.append style={
thick round path
},
}

\begin{document}

\section{No \texttt{spy} library}
\begin{tikzpicture}
\draw (0,.2) -- (1,0) -- (0,-.2);
\end{tikzpicture}

\section{\texttt{spy scope} set}
\begin{tikzpicture}[spy scope]
\draw (0,.2) -- (1,0) -- (0,-.2);
\end{tikzpicture}

\tikzset{
spy scope/.append style={
thick round path
},
}

\section{\texttt{spy scope} set but \texttt{spy scope/.append style} used}
\begin{tikzpicture}[spy scope]
\draw (0,.2) -- (1,0) -- (0,-.2);
\end{tikzpicture}

\section{Actually magnifying}
\begin{tikzpicture}[spy using outlines={circle, size=1cm, magnification=2}]
\draw (0,.2) -- (1,0) -- (0,-.2);
\spy on (1,0) in node at (2,0);
\end{tikzpicture}

\section{Setting property directly on drawn line}
\begin{tikzpicture}[spy using outlines={circle, size=1cm, magnification=2}]
\draw[thick round path] (0,.2) -- (1,0) -- (0,-.2);
\spy on (1,0) in node at (2,0);
\end{tikzpicture}

\end{document}


I would like to prevent having to specify a property to every line I draw since that can be many. Is there a different way to achieve what I want?

• Why not every path/.style={thick round path} – Salim Bou Jan 14 '17 at 15:35
• Well that is embarrassing. I didn't know about every path. Totally works. Do you want to make an answer out of your comment? – Artemis Jan 16 '17 at 9:07
• A small follow up: The every path solution prevents clip from working. The solution for this can be found here: tex.stackexchange.com/a/88222 – Artemis Jan 16 '17 at 9:27

\tikzset{