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}

次の結果を生成します ここに画像の説明を入力してください

参照記事に2つの画像を重ねる

どのように書き直す必要があるか

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}

ここに画像の説明を入力してください

関連情報