以下是我的代码:
\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}
结果是这样的: