我现在已经花了几个小时来解决我的问题 - 但没有任何进展。我想创建下图:
我的问题是,我不知道如何在中间创建一个额外的框。我的序言如下所示(感谢@Ignasi 为我指明了正确的方向):
\documentclass[margin=14pt,12pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[lf]{MinionPro}
\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, 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};
\foreach \i/\j in {1/d-left, 2/d-middle, 3/d-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.west);
\draw[ar] (\i)--(right.west|-\i);
}
\node[fit={(left) (right) ([yshift=2cm]d-left.north west)}, draw, inner sep=8,,] {};
\end{tikzpicture}
\end{document}
我将非常感激任何帮助!
答案1
只需添加一些yshift
适当的值(1.1厘米)和一个额外的节点middle21
。
\documentclass[margin=14pt,12pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
%\usepackage[lf]{MinionPro}
\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,yshift=1.1cm]
(middle2)
{2 text text text};
\node[mytext=4cm,right=1.5cm of left,yshift=-1.1cm]
(middle21)
{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,yshift=-1.1cm] (right)
{8 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};
\foreach \i/\j in {1/d-left, 2/d-middle, 3/d-right}
\draw ([yshift=1cm]\j.north west)--node [above] {\i\ text} ([yshift=1cm]\j.north east);
\foreach \i in {middle1, middle2,middle21, middle3}{
\draw[ar] (left.east)--(\i.west);
\draw[ar] (\i)--(right.west|-\i);
}
\node[fit={(left) (right) ([yshift=2cm]d-left.north west)}, draw, inner sep=8,,] {};
\end{tikzpicture}
\end{document}
答案2
这是一个使用calc
库将中间框放置在中间的选项;我试图修改原始代码,但可能性较小:
代码:
\documentclass[margin=14pt,12pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning, fit,calc}
\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,anchor=north west]
at ([xshift=1.5cm]$ (left.north east)!0.27!(left.south east) $ )
(middle2)
{2 text text text};
\node[mytext=4cm,anchor=south west]
at ([xshift=1.5cm]$ (left.north east)!0.73!(left.south east) $ )
(middle3)
{3 text text text};
\node[mytext=4cm,anchor=north west] at (left.north-|middle2.west)
(middle1)
{1 text text text};
\node[mytext=4cm,anchor=south west] at (left.south-|middle2.west)
(middle4)
{4 text text text};
\node[mytext=3cm,minimum height=8cm,right=1.5cm of middle1.north east,anchor=north west] (right)
{8 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};
\foreach \i/\j in {1/d-left, 2/d-middle, 3/d-right}
\draw ([yshift=1cm]\j.north west)--node [above] {\i\ text} ([yshift=1cm]\j.north east);
\foreach \i in {middle1, middle2, middle3, middle4}{
\draw[ar] (left.east)--(\i.west);
\draw[ar] (\i)--(right.west|-\i);
}
\node[fit={(left) (right) ([yshift=2cm]d-left.north west)}, draw, inner sep=8,,] {};
\end{tikzpicture}
\end{document}