![如何在tikz中使用座標?](https://rvso.com/image/254694/%E5%A6%82%E4%BD%95%E5%9C%A8tikz%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%BA%A7%E6%A8%99%EF%BC%9F.png)
以下是我的程式碼:
\begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
\coordinate (a1) [] {};
\node (rect) (a) [draw,minimum width=3cm,minimum height=1cm, below of=a1,node distance=1cm] {Sender};
\node[rectangle] (b) [draw,minimum width=3cm,minimum height=1cm, below of=a,node distance=2cm] {Receiver};
\coordinate (b1) [below=2cm of b] {};
\path[->] (a) edge node { $f$ } (b);
\path[->] (a1) edge node { $f$ } (a);
\path[->] (b) edge node { $f$ } (b1);
\end{tikzpicture}
我得到以下輸出:
我想要一個從接收器到 b1 的箭頭。
誰能告訴我我的錯誤嗎?
答案1
你的定義coordinate
方式很糟糕。你應該做這個:
\coordinate [below=2cm of b] (b1) {};
這樣,您的程式碼對我有用。
因此,您的完整程式碼應如下所示:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\begin{document}
\begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
\coordinate (a1) {};
\node (rect) (a) [draw,minimum width=3cm,minimum height=1cm, below of=a1,node distance=1cm] {Sender};
\node[rectangle] (b) [draw,minimum width=3cm,minimum height=1cm, below of=a,node distance=2cm] {Receiver};
\coordinate[below=2cm of b] (b1) {};
\path[->] (a) edge node { $f$ } (b);
\path[->] (a1) edge node { $f$ } (a);
\path[->] (b) edge node { $f$ } (b1);
\end{tikzpicture}
\end{document}
結果是這樣的: