在Tikz中在一个节点前输入一个箭头的方法

huangapple go评论109阅读模式
英文:

How to input an arrow before a node in Tikz

问题

目前,这是我有的部分代码,我不知道如何在节点前面输入一个箭头,带有“dr above”。以下是翻译好的部分:

\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 =S, 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$};

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

希望这能帮助你解决问题。谢谢你!

英文:

Im currently using Tikz to cite a mathematical model from a research but I don't know how to input an arrow before the node.

Here's a photo of the mathematical model that I'm trying to code:

在Tikz中在一个节点前输入一个箭头的方法

I don't know how to input the arrow entering the node F with dr above. Currently, this is all i have

\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 =S, 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$};

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

I hope anyone can help me resolve this problem. Thank you so much.

答案1

得分: 1

你可以在第一个框的左侧添加一个空节点,然后像处理其他箭头一样绘制箭头:

    \documentclass{beamer}
    
    \usepackage{tikz}
    \tikzset{
      Box/.style={
        rectangle, 
        rounded corners, 
        minimum width=1.25cm, 
        minimum height=1.25cm,
        text centered, 
        draw=black, 
        fill=yellow!30
      },
      arrow/.style={
        thick,
        ->,
        >=stealth
      }
    }
    
    \begin{document}
    	
    \begin{frame}
    
    \begin{figure}
    \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$};
      \node (foo) [left of=F] {};
      \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);
      \draw [arrow] (foo) -- node[above]{\textcolor{red}{dr}}(F);        
    \end{tikzpicture}
    \end{figure}
    
    \end{frame}	
    	
    \end{document}
英文:

You can add an empty node "left of" your first box and then draw the arrow just like you do for your other arrows:

\documentclass{beamer}

\usepackage{tikz}
\tikzset{
  Box/.style={
    rectangle, 
    rounded corners, 
    minimum width=1.25cm, 
    minimum height=1.25cm,
    text centered, 
    draw=black, 
    fill=yellow!30
  },
  arrow/.style={
    thick,
    ->,
    >=stealth
  }
}

\begin{document}
	
\begin{frame}

\begin{figure}
\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$};
  \node (foo) [left of=F] {};
  \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);
  \draw [arrow] (foo) -- node[above]{\textcolor{red}{dr}}(F);        
\end{tikzpicture}
\end{figure}

\end{frame}	
	
\end{document}

huangapple
  • 本文由 发表于 2023年3月9日 22:52:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75686247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定