座標を使用する場合のシフト

座標を使用する場合のシフト

座標についてよく分からないことがあるのですが、きっと説明してもらえると思います

これは問題の例です

\documentclass[tikz, border = 3pt]{standalone}

\usepackage{tikzpagenodes}

\begin{document}

\begin{tikzpicture}
  \coordinate (A) at (0, 0);
  \coordinate (B) at (4, 4);
  \draw (A) rectangle (B);

  \fill[red, xshift = 20pt] (B) circle (0.3) node[above = 7pt]{doesn't work};
  \fill[blue, xshift = 20pt] (0, 0) circle (0.3) node[below = 7pt]{works};
\end{tikzpicture}

\end{document}

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

問題は、shift例えば以前に定義された座標を使用しようとするときです。

\fill[red, xshift = 20pt] (B) circle (0.3);

写真でわかるように、円は明らかに移動しません。なぜでしょうか?

事前に感謝します

答え1

座標文字の近くにシフト オプションを適用すると、文字に割り当てられた座標で機能します\fill[red] ([xshift=20pt]B) circle (0.3) node[above = 7pt]{doesn't work};が、パスには機能しません。

\documentclass[tikz, border = 3pt]{standalone}

\usepackage{tikzpagenodes}

\begin{document}

\begin{tikzpicture}
  \coordinate (A) at (0, 0);
  \coordinate (B) at (4, 4);
  \draw (A) rectangle (B);

  \fill[red] ([xshift=20pt]B) circle (0.3) node[above = 7pt]{doesn't work};
  \fill[blue, xshift = 20pt] (0, 0) circle (0.3) node[below = 7pt]{works};
\end{tikzpicture}

\end{document}

関連情報