绘制网络架构

绘制网络架构

我想创建这个模式:想要的输出

但我被困在了这一点上。我不知道如何正确放置矩形,如何为服务器制作第二个箭头,以及最后如何在箭头上写信息。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{pgf}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{chains}
\usepackage{epstopdf}
\begin{document}
\begin{tikzpicture}
[
    start chain=going right,
    diagram item/.style={
        on chain, join    }
]


\filldraw[fill=gray!20] (0,0) rectangle (5,5);

\filldraw[fill=blue!20] (-5,-5) rectangle (2,2);
\node [
    diagram item,
    label=below:PC
] {\includegraphics{pc}};
\node [
    diagram item,
    label=below:Server of the school
] {\includegraphics{file_server.eps}};
\node [
    diagram item,
    label=center:Internet
] {\includegraphics{cloud}};
\node [
    start branch=1 going below right,
    diagram item,
    label=right:Public resolver DNS
] {\includegraphics{file_server.eps}};
\node [
    start branch=2 going right,
    diagram item,
    label=right:Public resolver DNS
] {\includegraphics{file_server.eps}};
\node [
    start branch=3 going above right,
    diagram item,
    label=right:Public resolver DNS
] {\includegraphics{file_server.eps}};
\end{tikzpicture}


\end{document}

输出如下输出 谢谢您的帮助

答案1

您可以使用backgroundsfit。由于我没有您的图形,并且我想提供一个每个人都可以运行的示例,因此我使用了一些示例图像。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{pgf}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{chains,fit,backgrounds}
\usepackage{epstopdf}
\begin{document}
\begin{tikzpicture}
[
    start chain=going right,
    diagram item/.style={
        on chain, join    }
]


\node [
    diagram item,
    label=below:PC
] (pc) {\includegraphics[width=1cm]{example-image-a}};
\node [
    diagram item,
    label=below:Server of the school
] (server1) {\includegraphics[width=1cm]{example-image-b}};
\node [
    diagram item,
    label=center:Internet
] (cloud) {\includegraphics[width=1cm]{example-image-c}};
\node [
    start branch=1 going below right,
    diagram item,
    label=right:Public resolver DNS
] (server2) {\includegraphics[width=1cm]{example-image-b}};
\node [
    start branch=2 going right,
    diagram item,
    label={[name=lbl5]right:Public resolver DNS}
] (server3) {\includegraphics[width=1cm]{example-image-b}};
\node [
    start branch=3 going above right,
    diagram item,
    label=right:Public resolver DNS
] (server4) {\includegraphics[width=1cm]{example-image-b}};

\begin{scope}[on background layer]
\path (server1) -- (cloud) coordinate[pos=0.95](aux1)
([xshift=-4mm,yshift=2cm]pc.north west) coordinate (aux2)
([yshift=-2cm]server1.south) coordinate (aux3)
([xshift=3mm]lbl5.east) coordinate (aux4)
([yshift=3mm]server4.north) coordinate (aux5)
([yshift=-3mm]server2.south) coordinate (aux6);
\node[fill=blue!20,inner sep=-\pgflinewidth/2,draw,
fit=(aux2) (aux3) (aux1)]{};
\node[fill=gray!20,inner sep=-\pgflinewidth/2,draw,
fit=(aux1) (aux4) (aux5) (aux6)]{};
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容