![带有容器、节点、箭头、框和 png 图像的多层 Tikz 图片](https://linux22.com/image/380737/%E5%B8%A6%E6%9C%89%E5%AE%B9%E5%99%A8%E3%80%81%E8%8A%82%E7%82%B9%E3%80%81%E7%AE%AD%E5%A4%B4%E3%80%81%E6%A1%86%E5%92%8C%20png%20%E5%9B%BE%E5%83%8F%E7%9A%84%E5%A4%9A%E5%B1%82%20Tikz%20%E5%9B%BE%E7%89%87.png)
我正在使用 tikz 为我的论文起草一个架构(见附件),并且遇到了很多困难。Tikz 架构需要整合 .png 图像。找到下面的代码来查看一些开发。
我还附上了需要纳入架构的所有 .png 图像。请帮我起草。
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows,
calc,
fit,
positioning,
shapes.geometric}
\tikzset{
rrbox/.style={%rounded red box,
rectangle,
draw, rounded corners, thick, fill=red!20,
minimum height=8mm, minimum width=24mm,
text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
align=center
},
sum/.style={% summation
circle,
draw=black, minimum size=8mm,
append after command={\pgfextra{\let\LN\tikzlastnode
\draw[thick,shorten >=1mm, shorten <=1mm, -]
(\LN.north) edge (\LN.south)
(\LN.west) to (\LN.east);
% \draw[blue] (\LN.center) circle (1.414*4 mm);
}},% end of nappend after command
node contents={}
},
disk/.style={% cylinder
cylinder, shape border rotate=90,
draw, fill=red!20,
aspect=0.25,
minimum height=12mm, minimum width=54mm,
align=center
},
container/.style={
rectangle,
draw, rounded corners,
inner sep=4mm, yshift=2mm,
node contents={}
},
line/.style={
draw, thick, dashed, -latex',
},
}% end of tikzset
\begin{document}
\begin{tikzpicture}[
node distance=8mm and 4mm,
]
% Container 1, on the left side
\node (sum) [sum]; % sumation
\node (a11) [rrbox, above left=4mm and 18mm of sum.west] {some text a11};
\node (a12) [rrbox, left =of a11] {some text a12};
\node (a21) [rrbox, below=of a11] {some text a21};
\node (a22) [rrbox, below=of a12] {some text a22};
\draw[line] (a12) edge (a11)
(a12) edge (a22)
(a11) edge (a21)
(a22) to (a21);
\node (container1) [container, fit=(a11) (a22),
label={[anchor=north]Some more Text}];
% Container 2, on the right side
\node (b11) [rrbox, above right=4mm and 18mm of sum.east] {some text b11};
\node (b12) [rrbox, right =of b11] {some text b12};
\node (b21) [rrbox, below=of $(b11.south)!0.5!(b12.south)$] {some text b21};
\draw[line] (b12) edge (b11)
(b11) edge (b21)
(b12) to (b21);
\node (container2) [container, fit=(b11) (b12) (b21),
label={[anchor=north]Some more Text}];
% Container 3, on the upper side
\node (c11) [rrbox, above=of sum] {some text c11};
\node (c12) [rrbox, above=of c11] {some text c12};
\draw[line] (c12) to (c11);
\node (container3) [container, fit=(c11) (c12),
label={[anchor=north]text}];
% cylinder
\node (d) [disk, below=of sum |- container1.south] {some text here\\in two
lines};
% Lines to and from the summation
\draw[line] (container1.east |- sum) edge (sum)
(container2.west |- sum) edge (sum)
(container3) edge (sum)
(sum) to ($(d.before top)!0.5!(d.after top)$);
%
\node(container4) [container, yshift=-2mm,
fit=(container1)(container2)(container3) (d)];
\node (e1) [rrbox, minimum width=50mm, below=of d] {Some Text \\ in e1};
\node (e2) [rrbox, minimum width=50mm, left=of e1] {Some Text \\ in e2};
\node (e3) [rrbox, minimum width=50mm, right=of e1] {Some Text \\ in e3};
\node (container5) [container,yshift=-1mm, below=of container4, fit=(e1) (e2)
(e3)];
\end{tikzpicture}
\end{document}
答案1
虽然只是所需图像的一部分,但它包含您可以自己完成的所有元素:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows,
calc,
fit,
positioning,
shapes.geometric,
shapes.multipart}
\usepackage{graphicx}
\tikzset{
rbox/.style={% red box,
rectangle,
draw, rounded corners, thick, fill=red!20,
minimum height=8mm, minimum width=24mm,
text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
align=center
},
ibox/.style={% image box,
rbox, draw=none, fill=#1
},
sum/.style={% summation
circle,
draw=black, minimum size=8mm,
append after command={\pgfextra{\let\LN\tikzlastnode
\draw[thick,shorten >=1mm, shorten <=1mm, -]
(\LN.north) edge (\LN.south)
(\LN.west) to (\LN.east);
}},% end of nappend after command
node contents={}
},
disk/.style={% cylinder
cylinder, shape border rotate=90,
draw, fill=red!20,
aspect=0.25,
minimum height=12mm, minimum width=54mm,
align=center
},
container/.style={
rectangle,
draw, rounded corners,
inner sep=4mm, yshift=2mm,
node contents={}
},
line/.style={
draw, thick, dashed, -latex',
},
}% end of tikzset
\begin{document}
\begin{tikzpicture}[
node distance=8mm and 4mm,
]
% Container 1, on the left side
\node (sum) [sum]; % sumation
\node (a11) [rbox, above left=4mm and 18mm of sum.west] {some text a11};
\node (a12) [rbox, left =of a11] {some text a12};
\node (a21) [rbox, below=of a11] {some text a21};
\node (a22) [rbox, below=of a12] {some text a22};
\draw[line] (a12) edge (a11)
(a12) edge (a22)
(a11) edge (a21)
(a22) to (a21);
\node (container1) [container, fit=(a11) (a22),
label={[anchor=north]Some more Text}];
% Container 2, on the right side
\node (b11) [rbox, above right=4mm and 18mm of sum.east] {some text b11};
\node (b12) [rbox, right =of b11] {some text b12};
\node (b21) [rbox, below=of $(b11.south)!0.5!(b12.south)$] {some text b21};
\draw[line] (b12) edge (b11)
(b11) edge (b21)
(b12) to (b21);
\node (container2) [container, fit=(b11) (b12) (b21),
label={[anchor=north]Some more Text}];
% Container 3, on the upper side
\node (c11) [rbox, above=of sum] {some text c11};
\node (c12) [rbox, above=of c11] {some text c12};
\draw[line] (c12) to (c11);
\node (container3) [container, fit=(c11) (c12),
label={[anchor=north]text}];
% cylinder
\node (d) [disk, below=of sum |- container1.south] {some text here\\(in two
lines)};
% Lines to and from the summation
\draw[line] (container1.east |- sum) edge (sum)
(container2.west |- sum) edge (sum)
(container3) edge (sum)
(sum) to ($(d.before top)!0.5!(d.after top)$);
%
\node(container4) [container, yshift=-2mm,
fit=(container1)(container2)(container3) (d),
label={[anchor=north east] 30:part 2}];
% part 3
\node (e2) [rbox, minimum width=50mm, below=16mm of d] {Some Text \\ in e1};
\node (e1) [rbox, minimum width=50mm, left =of e2] {Some Text \\ in e2};
\node (e3) [rbox, minimum width=50mm, right=of e2] {Some Text \\ in e3};
\node (i1) [ibox=white, below right=4mm and 0mm of e1.south west]
{some text\\xxxx xxxxx\\yy yy yy};
\node (i2) [ibox=red!20, right=of i1]
{\includegraphics[width=22mm]{example-image-duck}};
\node (i3) [ibox=white, below left=4mm and 0mm of e3.south east]
{some text\\xxxx xxxxx\\yy yy yy};
\node (i4) [ibox=red!20, left=of i3]
{\includegraphics[width=22mm]{example-image-duck}};
\node (container5) [container, fit=(e1) (i3),
label={[anchor=north east] 12:part 3}];
\draw[very thick, ->] (container4) -- (container5);
\end{tikzpicture}
\includegraphics[width=22mm]{example-image-duck}
\end{document}