Tikz 노드의 중심

Tikz 노드의 중심

@domenico-camasta로 인한 다음 코드

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}

\begin{figure}
    \begin{tikzpicture}
    \node(a){\includegraphics[width=0.8\textwidth]{example-image-a}};
    \node at (a.north east)
    [
    anchor=center,
    xshift=0mm,
    yshift=0mm
    ]
    {
        \includegraphics[width=0.3\textwidth]{example-image-b}
    };
    \end{tikzpicture}
\end{figure}

\end{document}

다음 결과를 생성합니다 여기에 이미지 설명을 입력하세요

또한보십시오기사에 두 개의 이미지를 겹쳐 놓습니다.

어떻게 다시 작성해야 합니까?

a.north east

위의 예에서 이미지 B를 배치하려면 다음을 수행하십시오.

1) 이미지 A의 중앙

2) 이미지 A의 동쪽 중앙에?

답변1

72장을 보십시오.tikz 및 pgf 매뉴얼도서관 에 대해서 shape. 여기서는 노드 모양 목록을 찾을 수 있으며 각 노드에 대해 기본 모양의 경우와 유사하게 미리 정의된 앵커가 있는 다이어그램이 표시됩니다 rectangle.

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

( 10130앵커는 단지 예일 뿐이며 0에서 360 사이의 각도를 사용할 수 있습니다.)

따라서 아래 코드와 같이 center및 앵커 뒤에 있습니다 .east

또한 노드 내용과 테두리 사이의 "패딩"을 제거하기 위해 노드 inner sep=0에 대해 설정하려고 할 수도 있습니다 .a

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

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}

\begin{figure}
    \begin{tikzpicture}
    \node [inner sep=0] (a){\includegraphics[width=0.8\textwidth]{example-image}};
    \node at (a.north east)
    [
    anchor=center,
    xshift=0mm,
    yshift=0mm
    ]
    {
        \includegraphics[width=0.3\textwidth]{example-image-a}
    };
    \node at (a.center) {\includegraphics[width=0.3\textwidth]{example-image-b}};
    \node at (a.east) {\includegraphics[width=0.3\textwidth]{example-image-c}};
    \end{tikzpicture}
\end{figure}

\end{document}

답변2

기본 위치 지정은 을 사용 center하고 기본 앵커는 이므로 center노드 node at (a)를 에 배치합니다 a.center. 따라서 중앙 동쪽 위치는 입니다 east.

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}

\begin{figure}
    \begin{tikzpicture}
    \node(a)[inner sep=0pt]{\includegraphics[width=0.8\textwidth]{example-image-a}};
    \node at (a)
    {
        \includegraphics[width=0.3\textwidth]{example-image-b}
    }
    node at (a.east)
    {
        \includegraphics[width=0.3\textwidth]{example-image-b}
    };
    \end{tikzpicture}
\end{figure}

\end{document}

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

관련 정보