
spy
현재 설치에서 라이브러리를 작동시키는 데 문제가 있습니다 . 저는 Win8.1x64에서 MikTeX 2.9(모든 패키지가 업데이트됨)와 함께 TeXmaker를 실행하고 있습니다.
다른 사람들이 이 문제에 대해 겪고 있는 문제에 대해 읽었습니다.여기그리고여기, 그러나 직접 PDF 출력과 함께 PdfLaTeX를 사용하여 작동하지 않습니다.
제가 사용하고 있는 MWE는 다음과 같습니다.
\documentclass{minimal}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,spy}
\begin{document}
\begin{tikzpicture}
% Using Wikipedia's image of the day
\node[anchor=south west,inner sep=0] (image) at (0,0){\includegraphics[width=0.65\textwidth]{Coiled_Galaxy.jpg}};
\begin{scope}[x={(image.south east)},y={(image.north west)},
spy using outlines={red,circle,magnification=4, size=3cm,connect spies}]
% \foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
% \foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
\spy on (0.70,0.95) in node at (0.5,1.2);
\end{scope}
\end{tikzpicture}
\\
Pgf Version: \pgfversion
\end{document}
% Log
% This is pdfTeX, Version 3.14159265-2.6-1.40.16 (MiKTeX 2.9) (preloaded format=pdflatex 2015.7.29)
그리고 이것이 내 결과입니다:
편집하다: 내 실수는 Ulrike Fischer가 지적했듯이 스파이가 작업할 수 있는 이미지가 없고 내 패키지와 아무 관련이 없다는 것입니다.
고정 솔루션은 다음과 같습니다.
\documentclass{minimal}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,spy}
\begin{document}
\begin{tikzpicture}[ spy using outlines={red,circle,magnification=4, size=3cm,connect spies}]
% Use Wikipedias image of the day
\node[anchor=south west,inner sep=0] (image) at (0,0){\includegraphics[width=0.65\textwidth]{Coiled_Galaxy.jpg}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
\end{scope}
\spy on ($0.95*(image.south east)+0.95*(image.north west)$) in node at ([yshift=1cm]image.north);
\end{tikzpicture}
\\
Pgf Version: \pgfversion
\end{document}
답변1
이 답변과 매우 유사한 것을 다른 곳에서 본 것 같지만 찾을 수 없습니다. 그러나 어쨌든 여기에는 상대 좌표(~부터)와 정확한 좌표(예: 단위 포함)를 모두 사용하여 이미지의 좌표(실제로는 0과 가 있어야 하는 이미지를 포함하는 노드) 를 참조 image
하는 방법을 제공하는 좌표계가 있습니다 .innersep
outersep
0
1
이 예 universe.jpg
에서는강사패키지. image cs
노드를 회전하거나 기울이는 것과 같은 "영리한" 작업을 수행하면 좋은 결과가 나오지 않습니다 .
\documentclass[tikz, border=5]{standalone}
\usetikzlibrary{spy}
\tikzdeclarecoordinatesystem{image}{%
\tikzset{image cs/.cd, #1}%
\pgfpointdiff%
{\pgfpointanchor{\graphicname}{south west}}%
{\pgfpointanchor{\graphicname}{north east}}%
\pgfgetlastxy\graphicwidth\graphicheight%
\pgfmathparse{\graphicx}%
\ifpgfmathunitsdeclared\def\graphicwidth{1}\fi%
\pgfmathparse{\graphicy}%
\ifpgfmathunitsdeclared\def\graphicheight{1}\fi%
\pgfpointadd{\pgfpointanchor{\graphicname}{south west}}%
{\pgfpoint{(\graphicx)*\graphicwidth}{(\graphicy)*\graphicheight}}%
}
\tikzset{image cs/.cd,
x/.store in=\graphicx, y/.store in=\graphicy,
image/.store in=\graphicname
}
\begin{document}
\begin{tikzpicture}
\begin{scope}[spy using outlines={white, ultra thick,
circle, magnification=4, size=3cm, connect spies}]
\node [inner sep=0, outer sep=0] (universe)
{\includegraphics[width=10cm]{universe.jpg}};
\foreach \x in {0,1,...,9}{
\node [below] at (image cs:image=universe, x=\x/10, y=0) {0.\x};
\node [above] at (image cs:image=universe, x=\x cm, y=1) {\x cm};
}
\foreach \y in {0,1,...,9}{
\node [left] at (image cs:image=universe, x=0, y=\y/10) {0.\y};
\node [right] at (image cs:image=universe, x=1, y=\y cm) {\y cm};
}
\spy on (image cs:image=universe, x=0.69, y=0.88) in node at (-2, 5);
\spy on (image cs:image=universe, x=5cm, y=5cm) in node at (-5, 0);
\spy on (image cs:image=universe, x=0.41, y=0.12) in node at ( 5,-5);
\end{scope}
\end{tikzpicture}
\end{document}