帮助向 TikZ 添加箭头和方框

帮助向 TikZ 添加箭头和方框

我有一个 TikZ 图,我想修改它。我是 TikZ 新手,如果有人能帮忙,我将不胜感激。我的图是一个带有箭头和数字的流程图:

\tikzstyle{int}=[draw, fill=blue!20, minimum size=2em]
\tikzstyle{init} = [pin edge={to-,black}]

\begin{tikzpicture}[node distance=4.5cm,auto,>=latex']
    \node [int, pin={[init]below:Input2}] (a) {Box1};
    \node (b) [left of=a,node distance=4.5cm, coordinate] {a};
    \node [int] (c) [right of=a] {Box2};
    \node [coordinate] (end) [right of=c, node distance=3.5cm]{};
    \path[->] (b) edge node {Arrow1} (a);
    \path[->] (a) edge node {Arrow2} (c);
    \draw[->] (c) edge node {Arrow3}  (end) ;
\end{tikzpicture}

我想要得到这样的东西:这些。(我有两个不同的图表,它不代表单个图像。)我从哪里开始?

答案1

试试这个代码:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\tikzstyle{int}=[draw, fill=blue!20, minimum size=2em]
\tikzstyle{init} = [pin edge={to-,black}]
\begin{document}
    \begin{tikzpicture}[node distance=4.5cm]
        \node [int, pin={[init]below:Input1}] (a) {Box1};
        \node (b) [left of=a, coordinate] {a};
        \node [int, pin={[init]below:Input2}] (c) [right of=a] {Box2};
        \node [coordinate] (end) [right of=c]{};
        \path[->] (b) edge node[midway,above] {Arrow1} (a);
        \path[->] (a) edge node[midway,above] {Arrow2} (c);
        \draw[->] (c) edge node[midway,above] {Arrow3}  (end) ;
    \end{tikzpicture}
    
\end{document}

产生以下输出:

在此处输入图片描述

编辑1:

新代码:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\tikzstyle{int}=[draw, fill=blue!20, minimum size=2em]
\tikzstyle{init} = [pin edge={to-,black}]
\begin{document}
    \begin{tikzpicture}[node distance=3.5cm]
        \node [int, pin={[init]}] (a) {Input1};
        \node (b) [left of=a, coordinate] {a};
        \node [int, pin={[init]}] (c) [right of=a] {Input2};
        \node [coordinate] (end) [right of=c]{};
        \path[->] (b) edge node[midway,above] {Arrow1} (a);
        \path[->] (a) edge node[midway,above] {Arrow2} (c);
        \draw[->] (c) edge node[midway,above] {Arrow3}  (end) ;
    \end{tikzpicture}
    
\end{document}

新输出:

在此处输入图片描述

编辑2:

如果您不想在输入框上方出现箭头,请尝试以下代码:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\tikzstyle{int}=[draw, fill=blue!20, minimum size=2em]
\tikzstyle{init} = [pin edge={to-,black}]
\begin{document}
    \begin{tikzpicture}[node distance=3.5cm]
    %   \node [int, pin={[init]}] (a) {Input1};
        \node [int] (a) {Input1};
        \node (b) [left of=a, coordinate] {a};
    %   \node [int, pin={[init]}] (c) [right of=a] {Input2};
        \node [int] (c) [right of=a] {Input2};
        \node [coordinate] (end) [right of=c]{};
        \path[->] (b) edge node[midway,above] {Arrow1} (a);
        \path[->] (a) edge node[midway,above] {Arrow2} (c);
        \draw[->] (c) edge node[midway,above] {Arrow3}  (end) ;
    \end{tikzpicture}
    
\end{document}

产生输出:

在此处输入图片描述

相关内容