tikz의 노드 사이에 이미지 배치: 정확한 위치 지정을 달성하는 방법

tikz의 노드 사이에 이미지 배치: 정확한 위치 지정을 달성하는 방법

tikz/pgf 도면에 배경 이미지를 포함하려고 합니다. 이미지의 특정 특징에 직접 노드를 그릴 수 있어야 하므로 정확하게 조정해야 합니다.

다음과 같이 이미지의 모서리를 정의하는 두 개의 노드로 어떻게든 수정할 수 있다면 가장 쉬울 것입니다.

\documentclass{article}
\usepackage{pgf,tikz}
\begin{document}
\begin{tikzpicture}
\node at (0,0) {a};
\includegraphics{something.png}
\node at (2,2) {b};
\end{tikzpicture}
\end{document}

물론 이것은 내가 원하는 것을 수행하지 않습니다. 즉, 오른쪽 상단 모서리가 (2,2)에 있고 왼쪽 하단 모서리가 (0,0)에 있도록 이미지 크기를 조정하는 것입니다.

여기에 이미지 설명을 입력하세요

답변1

@percusse의 댓글을 보고 정답을 찾았습니다. 여기에는 범위 환경 사용이 포함됩니다.

다음 코드는 @Caramdir의 답변에서 가져온 것입니다.TikZ로 이미지 그리기:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.9\textwidth]{some_image.jpg}};
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
        \draw[red,ultra thick,rounded corners] (0.62,0.65) rectangle (0.78,0.75);
    \end{scope}
\end{tikzpicture}
\end{document}

답변2

이건 어때?

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt] (img) at (0,0) {\includegraphics{example-image-a}};
\coordinate (a) at (img.south west);
\coordinate (b) at (img.north east);
\draw[blue,thick] (a)--(b);
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보