I am trying to make a picture like this in LaTeX. Any ideas how I would do this?
- 54,118
- 259
1 Answers
Apart from the fact that there is no MWE, I think this is in principle an interesting question. As pointed out by Jojo, one can use spy here. However, there are two slightly nontrivial aspects:
- How can one connect the spy nodes by tangents?
- How can one spy on a spy node?
The first subquestion has been addressed here but I simplified the answer quite a bit using this observation. Now one can use
\spy [size=1cm,tangent connect] on (0,0) in node [below] at (1,-1);
to get the tangent connection. As for the second subquestion, I'd assume that the answer is well known but I did not find this simple answer on this site (nor elsewhere): just use different scopes. Of course, I may just have missed it. Anyway, here is a code. (Needless to say that I do not understand the axis labeling.)
\documentclass[tikz,border=3mm]{standalone}
\usepackage{dsfont}% you can also use amsfonts but I personally like
% the dsfont double-stroke letters a little bit better
\usetikzlibrary{calc,spy}
\begin{document}
\begin{tikzpicture}[spy using outlines={circle, magnification=4,size=2cm,connect spies},
tangent connect/.style={spy connection path={
\draw[thin] let \p1=(tikzspyonnode.center),\p2=(tikzspyonnode.north),
\p3=(tikzspyinnode.center),\p4=(tikzspyinnode.north),
\n1={atan2(\y3-\y1,\x3-\x1)}, % slope between circle centers
\n2={veclen(\y3-\y1,\x3-\x1)},
\n3={atan2(\y4-\y3-\y2+\y1,\n2)} % additional slope because of different radii
in
(tikzspyonnode.\n3+\n1+90) -- (tikzspyinnode.\n3+\n1+90)
(tikzspyonnode.-\n3+\n1-90) -- (tikzspyinnode.-\n3+\n1-90);}}]
\begin{scope}[spy using outlines={circle, magnification=4,size=2cm,connect spies}]
\draw[-stealth] (-2.5,0) -- (5,0) node[right]{$-x^2$};
\draw[-stealth] (0,-1.5) -- (0,1.5)node[left]{$\mathds{C}$};
\draw[trig format=rad] plot[domain=-2.5:4.6,smooth,samples=151]
(\x,{0.5*sin(pi*\x)});
\spy [size=1cm,tangent connect] on (0,0) in node [below] at (1,-1);
\spy [size=1cm,tangent connect] on (4.5,0.5) in node at (5.5,1.3);
\end{scope}
\spy [size=1cm,tangent connect] on (5.5,1.3) in node at (6.8,1.6);
\end{tikzpicture}
\end{document}
And things that are not in the (inner) spy scope do not get spied on by the (inner) spies. (Of course here things are particularly easy as everything is black so the drawing order does not matter. In more complicated settings one may need to use layers, which is somewhat nontrivial in the context of spy.)
\documentclass[tikz,border=3mm]{standalone}
\usepackage{dsfont}% you can also use amsfonts but I personally like
% the dsfont double-stroke letters a little bit better
\usetikzlibrary{calc,spy}
\begin{document}
\begin{tikzpicture}[spy using outlines={circle, magnification=4,size=2cm,connect spies},
tangent connect/.style={spy connection path={
\draw[thin] let \p1=(tikzspyonnode.center),\p2=(tikzspyonnode.north),
\p3=(tikzspyinnode.center),\p4=(tikzspyinnode.north),
\n1={atan2(\y3-\y1,\x3-\x1)}, % slope between circle centers
\n2={veclen(\y3-\y1,\x3-\x1)},
\n3={atan2(\y4-\y3-\y2+\y1,\n2)} % additional slope because of different radii
in
(tikzspyonnode.\n3+\n1+90) -- (tikzspyinnode.\n3+\n1+90)
(tikzspyonnode.-\n3+\n1-90) -- (tikzspyinnode.-\n3+\n1-90);}}]
\begin{scope}[spy using outlines={circle, magnification=4,size=2cm,connect spies}]
\draw[trig format=rad] plot[domain=-2.5:4.6,smooth,samples=151]
(\x,{0.5*sin(pi*\x)});
\spy [size=1cm,tangent connect] on (0,0) in node [below] at (1,-1);
\spy [size=1cm,tangent connect] on (4.5,0.5) in node at (5.5,1.3);
\end{scope}
\draw[-stealth] (-2.5,0) -- (5,0) node[right]{$-x^2$};
\draw[-stealth] (0,-1.5) -- (0,1.5)node[left]{$\mathds{C}$};
\spy [size=1cm,tangent connect] on (5.5,1.3) in node at (6.8,1.6);
\end{tikzpicture}
\end{document}
-
Your answer is between my favorities. I like very much spy library. – Sebastiano May 02 '20 at 20:52
-
Thank you so much! How do I suppress the axes on the localization at zero? – fdzsfhaS May 03 '20 at 01:44
-
@DavidWarrenKatz That's very easy, it is the same trick as described under 2. I added a version illustrating this. – May 03 '20 at 01:50



spylibrary, which is described e.g. in @Jojo's link. That way you typeset the formulae precisely as in the ambient LaTeX document. – May 02 '20 at 19:41