![如何在 tikz 中使用坐标?](https://linux22.com/image/254694/%E5%A6%82%E4%BD%95%E5%9C%A8%20tikz%20%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%9D%90%E6%A0%87%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}
结果是这样的: