
以下のコードは@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
シェイプの場合は次のようになります。
(10
と130
アンカーは単なる例であり、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}