使用座標時移動

使用座標時移動

關於座標,我不太明白,但我很確定你能夠解釋一下

這是問題的一個例子

\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}

相關內容