使用 tikz 绘制箭头

使用 tikz 绘制箭头

我正在尝试使用 tikz 包制作流程图。我的代码是:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,positioning,shapes.geometric}
\tikzstyle{intt}=[draw,text centered,minimum size=5em,text width=9cm,text height=0.34cm]
\tikzstyle{intl}=[draw,text centered,minimum size=2em,text width=2.75cm,text height=0.34cm]
\tikzstyle{int}=[draw,minimum size=2.5em,text centered,text width=2cm]
\tikzstyle{intg}=[draw,minimum size=5em,text centered,text width=9.cm]
\tikzstyle{sum}=[draw,shape=circle,inner sep=2pt,text centered,node distance=3.5cm]
\tikzstyle{summ}=[drawshape=circle,inner sep=4pt,text centered,node distance=3.cm]

\begin{document}

\begin{figure}[!htb]
\centering
\begin{tikzpicture}
  \node [intt] (kp)  {AAAA};
  \node [int]  (ki1) [node distance=2.5cm and 0cm,below left of=kp] {BBBB};
  \node [int]  (ki2) [node distance=3cm and   0cm,below of=kp] {CCCC};
  \node [int]  (ki3) [node distance=2.5cm and 0cm,below right of=kp] {DDDD};
  \node [intg] (ki4) [node distance=5cm,below of=kp] {EEEE};



  \draw[->] (ki1) -- (kp);
  \draw[->] (ki2) -- (kp);
  \draw[->] (ki3) -- (kp);
  \draw[->] ($(ki4.east)+(0,1)$) -- ($(kp.east)+(0,-1)$) node[above,pos=0.4,xshift=1cm] {FFFF};

\end{tikzpicture}
\caption{Caption}
\label{fig:datafusionindirectdirectfc}
\end{figure}


\end{document}

它给了我 在此处输入图片描述

但是我需要一个如下所示的图表

在此处输入图片描述

答案1

这不是最好的方法,但其中一种方法是指定节点的坐标——

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,positioning,shapes.geometric}
\tikzstyle{intt}=[draw,text centered,minimum size=5em,text width=9cm,text height=0.34cm]
\tikzstyle{intl}=[draw,text centered,minimum size=2em,text width=2.75cm,text height=0.34cm]
\tikzstyle{int}=[draw,minimum size=2.5em,text centered,text width=2cm]
\tikzstyle{intg}=[draw,minimum size=5em,text centered,text width=9.cm]
\tikzstyle{sum}=[draw,shape=circle,inner sep=2pt,text centered,node distance=3.5cm]
\tikzstyle{summ}=[drawshape=circle,inner sep=4pt,text centered,node distance=3.cm]

\begin{document}

    \begin{figure}[!htb]
        \centering
        \begin{tikzpicture}
        \node [intt] (kp)  {AAAA};
        \node [int]  (ki1) [node distance=2.5cm and 0cm] at (-3.5, -3) {BBBB};
        \node [int]  (ki2) [node distance=3cm and   0cm] at (-0.8,-3)  {CCCC};
        \node [int]  (ki3) [node distance=2.5cm and 0cm] at (1.9,-3) {DDDD};
        \node [intg] (ki4) [node distance=5cm,below of=kp] {EEEE};



        \draw[->] (ki1) -- (-3.5,-1);
        \draw[->] (ki2) -- (-0.8,-1);
        \draw[->] (ki3) -- (1.9, -1);
        \draw[->] ($(ki4.east)+(-1,1)$) -- ($(kp.east)+(-1,-1)$) node[above,pos=0.4,xshift=0.6cm] {FFFF};

        \end{tikzpicture}
        \caption{Caption}
        \label{fig:datafusionindirectdirectfc}
    \end{figure}


\end{document}

输出如下——

在此处输入图片描述

答案2

@Amit 的另一种选择,不错的答案。主要区别是:

  • 而是tikzstyle使用\tikzset
  • 所有坐标均相对于第一个节点

完整代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, calc, positioning}

\tikzset{
  box/.style = {draw, text centered, outer sep=1mm},
 intt/.style = {box, text width=9cm, minimum height=5.0em},
  int/.style = {box, text width=2cm, minimum height=2.5em},
        }

\begin{document}
    \begin{figure}[htb]
        \centering
    \begin{tikzpicture}[
    node distance = 5mm and 2mm
                        ]
\node (kp)  [intt]  {AAAA};
\node (ki1) [int, below right=
            5mm and 0mm of kp.south west]   {BBBB};
\node (ki2) [int, right=of ki1]             {CCCC};
\node (ki3) [int, right=of ki2]             {DDDD};
\node (ki4) [intt,below right=
            5mm and 0mm of ki1.south west]  {EEEE};
%
\draw[->]   (ki1) edge (ki1 |- kp.south)
            (ki2) edge (ki2 |- kp.south)
            (ki3) edge (ki3 |- kp.south);
\draw[->,transform canvas={xshift=5mm}]   
    (ki4.north -| ki3.east) -- node[right] {FFFF}
    ( kp.south -| ki3.east);
    \end{tikzpicture}
\caption{Caption}
\label{fig:datafusionindirectdirectfc}
    \end{figure}
\end{document}

如您所见,\tikzset我省略了所有未使用的样式,并为节点定义了通用样式,该样式用于所有其他具有矩形形状的节点。结果几乎相同:

在此处输入图片描述

相关内容