I'd like to use a tikz spy shaped like a chamfered rectangle.
The code runs without complaining, but the result is a plain rectangle.
"rounded rectangle" works as expected, as does chamfered-rectangle-shaped non-spy nodes. How could I fix this?
The code below should demonstrate my problem. Unfortunately I don't have enough rep to add a picture..
pdflatex Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
I had the same issue in Windows yesterday, I believe that was Tex Live 2012 as well.
tikz 2010/10/13 v2.10 (rcs-revision 1.76)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{spy,decorations.fractals,shapes.misc}
\begin{document}
\tikz\node[draw, circle] {circle};
\begin{tikzpicture}
[spy using outlines={circle, magnification=3, size=1cm, connect spies}]
\draw [decoration=Koch curve type 1]
decorate{ decorate{ decorate{ (0,0) -- (2,0) }}};
\spy [red] on (1.6,0.3) in node at (3,1);
\end{tikzpicture}
\tikz\node[draw, rounded rectangle] {rounded rectangle};
\begin{tikzpicture}
[spy using outlines={rounded rectangle, magnification=3, width=2cm, height=1cm, connect spies}]
\draw [decoration=Koch curve type 1]
decorate{ decorate{ decorate{ (0,0) -- (2,0) }}};
\spy [red] on (1.6,0.3) in node at (3,1);
\end{tikzpicture}
\tikz\node[draw, chamfered rectangle] {chamfered rectangle};
\begin{tikzpicture}
[spy using outlines={chamfered rectangle, magnification=3, width=2cm, height=1cm, connect spies}]
\draw [decoration=Koch curve type 1]
decorate{ decorate{ decorate{ (0,0) -- (2,0) }}};
\spy [red] on (1.6,0.3) in node at (3,1);
\end{tikzpicture}
\end{document}
Here's what it produces for me:
Best Answer
The
chamfered rectangle
shape uses the height, depth and width of the node’s text box as well as the inner separator to compute its path (as every other shape).This can be simulated with a normal node with
inner sep
set to zero (the spy nodes use this too):So, the next idea would be to include an
inner sep
again in theevery spy on node
as well as theevery spy in node
.My other solution provides a specific fix for the
chamfered rectangle
which will use theminimum height
andminimum width
as a replacement for the text box.The yellow box shows in both solutions where the
2cm × 1cm
will be measured.Code A (
inner sep
)Code B (specific fix)
Output (both)