新问题:创建图形的严重问题

新问题:创建图形的严重问题

我现在正在尝试制作这个模型:

在此处输入图片描述

但我不知道如何在顶部添加节点;“1 text”、“2 text”、“3 text”和“4 text”。此外,我不知道如何制作第四个框,如下所示:“9 text text”。

我的序言如下:

    \documentclass{article}
    \usepackage{tikz}

    \begin{document}

    \begin{tikzpicture}[
    mytext/.style={
      draw,
      text width=#1,
      align=center,
      minimum height=1.5cm
      },
    ar/.style={
      ->,
      >=latex
      }  
    ]
    \node[mytext=3cm,minimum height=8cm] (left)
      {2 text text text};
    \node[mytext=4cm,anchor=north west] 
      at ([xshift=1.5cm]left.north east) (middle1)
      {4 text text text};
    \node[mytext=4cm,anchor=west] 
      at ([xshift=1.5cm]left.east) (middle2)
      {5 text text text};
    \node[mytext=4cm,anchor=south west] 
      at ([xshift=1.5cm]left.south east) (middle3)
      {6 text text text};
    \node[mytext=3cm,minimum height=8cm,anchor=north west] 
      at ([xshift=1.5cm]middle1.north east) (right)
      {8 text text text};
    \coordinate (aux) at ([yshift=3cm]middle1);
    \node[mytext=4cm,dashed,minimum height=0.8cm,anchor=north] 
      at (aux) (middle0)
      {3 text text};  
    \node[mytext=3cm,dashed,anchor=north] 
      at (left.center|-aux) (left0)
      {1 text text};  
    \node[mytext=3cm,dashed,anchor=north] 
      at (right.center|-aux) (right0)
      {7 text text};
    \draw
      ([shift={(-10pt,10pt)}]left0.north west)
        rectangle
      ([shift={(10pt,-10pt)}]right.south east);

    \foreach \Valor in {1,2,3}
    {
    \draw[ar]
      (left.east|-middle\Valor.west) -- (middle\Valor.west);    
    \draw[ar]
      (middle\Valor.east) -- (right.west|-middle\Valor.west);    
    }
    \end{tikzpicture}

    \end{document}

EDIT:

@Ignasi have been very helpful to create the figure above - by using this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit}

\begin{document}

\begin{tikzpicture}[
mytext/.style={
  draw,
  text width=#1,
  align=center,
  minimum height=1.5cm
  },
ar/.style={
  ->,
  >=latex
  }  
]
\node[mytext=3cm,minimum height=8cm] (left)
  {1 text text text};
\node[mytext=4cm,right=1.5cm of left] (middle2)
  {2 text text text};
\node[mytext=4cm,anchor=north west] at (left.north-|middle2.west) 
  (middle1)
  {3 text text text};
\node[mytext=4cm,anchor=south west] at (left.south-|middle2.west) 
  (middle3)
  {4 text text text};
\node[mytext=3cm,minimum height=8cm,right=1.5cm of middle2] (right)
  {8 text text text};
\node[mytext=3cm,minimum height=8cm,right=1.5cm of right] (right-right)
  {9 text text text};

\node[mytext=3cm, dashed, above=1cm of left] (d-left) {1 text text};
\node[mytext=4cm, dashed, above=1cm of middle1] (d-middle) {2 text text};
\node[mytext=3cm, dashed, above=1cm of right] (d-right) {3 text text};
\node[mytext=3cm, dashed, above=1cm of right-right] (d-right-right) {4 text text};

\foreach \i/\j in {1/d-left, 2/d-middle, 3/d-right, 4/d-right-right}
    \draw ([yshift=1cm]\j.north west)--node [above] {\i\ text} ([yshift=1cm]\j.north east);

\foreach \i in {middle1, middle2, middle3}{
    \draw[ar] (left.east|-\i)--(\i);
    \draw[ar] (\i)--(right.west|-\i);
    }

\draw[ar] (right) -- (right-right);

\node[fit={(left) (right-right) ([yshift=2cm]d-left.north west)}, draw, inner sep=8,,] {};
\end{tikzpicture}

\end{document}

我的问题是:通过更改上面的代码,是否可以轻松创建下表?

编辑

@Ignasi 非常出色地使用以下代码示例创建了上图:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit}

\begin{document}

\begin{tikzpicture}[
mytext/.style={
  draw,
  text width=#1,
  align=center,
  minimum height=1.5cm
  },
ar/.style={
  ->,
  >=latex
  }  
]
\node[mytext=3cm,minimum height=8cm] (left)
  {1 text text text};
\node[mytext=4cm,right=1.5cm of left] (middle2)
  {2 text text text};
\node[mytext=4cm,anchor=north west] at (left.north-|middle2.west) 
  (middle1)
  {3 text text text};
\node[mytext=4cm,anchor=south west] at (left.south-|middle2.west) 
  (middle3)
  {4 text text text};
\node[mytext=3cm,minimum height=8cm,right=1.5cm of middle2] (right)
  {8 text text text};
\node[mytext=3cm,minimum height=8cm,right=1.5cm of right] (right-right)
  {9 text text text};

\node[mytext=3cm, dashed, above=1cm of left] (d-left) {1 text text};
\node[mytext=4cm, dashed, above=1cm of middle1] (d-middle) {2 text text};
\node[mytext=3cm, dashed, above=1cm of right] (d-right) {3 text text};
\node[mytext=3cm, dashed, above=1cm of right-right] (d-right-right) {4 text text};

\foreach \i/\j in {1/d-left, 2/d-middle, 3/d-right, 4/d-right-right}
    \draw ([yshift=1cm]\j.north west)--node [above] {\i\ text} ([yshift=1cm]\j.north east);

\foreach \i in {middle1, middle2, middle3}{
    \draw[ar] (left.east|-\i)--(\i);
    \draw[ar] (\i)--(right.west|-\i);
    }

\draw[ar] (right) -- (right-right);

\node[fit={(left) (right-right) ([yshift=2cm]d-left.north west)}, draw, inner sep=8,,] {};
\end{tikzpicture}

\end{document}

我想知道是否可以通过对示例代码进行一些更改来创建下图?如能提供任何帮助我将不胜感激!

在此处输入图片描述

答案1

我建议使用positioning可以帮助您将节点放置在其他节点旁边/上方/下方的库。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit}

\begin{document}

\begin{tikzpicture}[
mytext/.style={
  draw,
  text width=#1,
  align=center,
  minimum height=1.5cm
  },
ar/.style={
  ->,
  >=latex
  }  
]
\node[mytext=3cm,minimum height=8cm] (left)
  {1 text text text};
\node[mytext=4cm,right=1.5cm of left] (middle2)
  {2 text text text};
\node[mytext=4cm,anchor=north west] at (left.north-|middle2.west) 
  (middle1)
  {3 text text text};
\node[mytext=4cm,anchor=south west] at (left.south-|middle2.west) 
  (middle3)
  {4 text text text};
\node[mytext=3cm,minimum height=8cm,right=1.5cm of middle2] (right)
  {8 text text text};
\node[mytext=3cm,minimum height=8cm,right=1.5cm of right] (right-right)
  {9 text text text};

\node[mytext=3cm, dashed, above=1cm of left] (d-left) {1 text text};
\node[mytext=4cm, dashed, above=1cm of middle1] (d-middle) {2 text text};
\node[mytext=3cm, dashed, above=1cm of right] (d-right) {3 text text};
\node[mytext=3cm, dashed, above=1cm of right-right] (d-right-right) {4 text text};

\foreach \i/\j in {1/d-left, 2/d-middle, 3/d-right, 4/d-right-right}
    \draw ([yshift=1cm]\j.north west)--node [above] {\i\ text} ([yshift=1cm]\j.north east);

\foreach \i in {middle1, middle2, middle3}{
    \draw[ar] (left.east|-\i)--(\i);
    \draw[ar] (\i)--(right.west|-\i);
    }

\draw[ar] (right) -- (right-right);

\node[fit={(left) (right-right) ([yshift=2cm]d-left.north west)}, draw, inner sep=8,,] {};
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容