2

I want to create this schema :Output wanted

But I'm stuck at this point. I don't know how to properly place the rectangles, how to make a second arrow for the server and finally how to write informations on the arrows.

\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}

Here is the output Output Thanks for the help

3
  • You should try the fit library perhaps ... – Jasper Habicht Oct 31 '18 at 13:14
  • You can use backgrounds and fit for that, but we do not have your graphics files that you include. – user121799 Oct 31 '18 at 13:14
  • Here is my graphics : imgur.com/a/ZLQsUS2 – Warok Oct 31 '18 at 13:23
2

You can use backgrounds and fit for that. Since I do not have your graphics and since I want to provide an example that can be run by everyone, I use some example images.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.