如何在Tikz中给节点F添加带dr标注的前置箭头?
TikZ 节点输入箭头添加方案
问题修正与箭头添加说明
- 原代码存在一处错误:节点
D的定位参数right of =S中的S未定义,需改为right of=F。 - 给节点
F添加上方标注为dr的输入箭头,可通过定位节点左侧位置绘制箭头,并在箭头上方添加标注实现。
完整修正代码
\tikzstyle{Box} = [rectangle, rounded corners, minimum width=1.25cm, minimum height=1.25cm, text centered, draw=black, fill=yellow!30] \tikzstyle{arrow} = [thick,->,>=stealth] \begin{center} \begin{figure} \centering \begin{tikzpicture}[node distance=2cm] \node (F) [Box, label=above:{\textcolor{red}{$I_1$}}] {$F$}; \ \node (D) [Box, right of =F, label=above:{\textcolor{red}{$I_2$}}] {$D$}; \ \node (W) [Box, right of =D, label=above:{\textcolor{red}{$I_3$}}] {$W$}; \ \node (R) [Box, right of =W, label=above:{\textcolor{red}{$I_4$}}] {$R$}; % 添加指向F的输入箭头,标注为dr \draw [arrow] ([xshift=-1cm]F.west) -- node[above] {$dr$} (F.west); \draw [arrow] (F) -- node[above]{\textcolor{red}{$\varphi_1$}}(D); \draw [arrow] (D) -- node[above]{\textcolor{red}{$\varphi_2$}}(W); \draw [arrow] (W) -- node[above]{\textcolor{red}{$\varphi_3$}}(R); \end{tikzpicture} \end{figure} \end{center}
关键代码解释
[xshift=-1cm]F.west:定位到节点F左侧边缘向左偏移1cm的位置,作为箭头起点node[above] {$dr$}:在箭头上方添加标注文本dr,如果需要和其他标注同色,可改为node[above]{\textcolor{red}{$dr$}}
内容的提问来源于stack exchange,提问作者Unique
相关产品推荐
相关产品推荐

