如何在tikz中使用座標?

如何在tikz中使用座標?

以下是我的程式碼:

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

結果是這樣的:

在此輸入影像描述

相關內容