2

I'm trying on my first tikz diagram, and it's working okay, but I've run into some problems and I think that my solution is starting to be more discretionary. Heres my code:

\documentclass[png,border=10pt,tikz]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,fit,shapes,calc}
\tikzset{
    state/.style={
           rectangle,
           rounded corners,
           draw=black, very thick,
           minimum height=2em,
           inner sep=2pt,
           text centered,
           },
}

\tikzstyle{line} = [draw, -latex]

\pgfdeclarelayer{bg}    % declare background layer
\pgfsetlayers{bg,main}

\begin{document}


\tikzset{
    block/.style={draw, fill=white, rectangle, rounded corners, 
            minimum height=2em, minimum width=10em},
    block2/.style={draw, fill=white, rectangle, rounded corners, 
            minimum height=2em, minimum width=10em},  
    block3/.style={draw, fill=white, rectangle, 
            minimum height=4em, minimum width=30em},             
}

\begin{tikzpicture}[auto, node distance=2.5cm, >=latex]

\node[block3] (kronos) {Kronos};
\node[block, above of= kronos, anchor=north east] (interbank) {Interbank};
\node[block, above of= kronos, anchor=north west] (pengepolitik) {Pengepolitiske operationer};

\node[block, below = of kronos, anchor=south] (sum) {Sum-, intraday- og Straksclearing};
\node[block, left of = sum] (scp) {SCP};
\node[block, left = of scp] (vp) {VP};

\node[block, right of = sum] (euro) {EuroCCP};
\node[block, right of = euro] (cls) {CLS}; 

\node[block, below of= vp] (valuta) {Valutahandler};
\node[block, below of= scp] (detail) {Detailhandler};
\node[block, below of= cls] (værdi) {Værdipapirhandler};

\draw[dotted,thick] ($(interbank.north west)+(-0.3,0.3)$) rectangle ($(pengepolitik.south east)+(0.3,-0.3)$);

\draw[dotted,thick] ($(vp.north west)+(-0.3,0.3)$) rectangle ($(cls.south east)+(0.3,-0.3)$);



\path[line] (pengepolitik) -- (kronos);
\path[line] (interbank) -- (kronos);
\path[line] (scp) -- (kronos);
\path[line] (euro) -- (kronos);
\path[line] (vp) -- (kronos);
\path[line] (cls) -- (kronos);

\begin{pgfonlayer}{bg}    % select the background layer
       \draw[dashed] ($(kronos.west)+(-6,0)$) -- ($(kronos.east)+(6,0)$);
    \end{pgfonlayer}


\end{tikzpicture}



\end{document}

Some of my problems are pretty obvious:

enter image description here

But I'm trying to achieve something like this: enter image description here

Therefor i'm also looking for a way to do the straigth lines instead of lines going to the center of the main figure? Do you have a better solution that I could try to do?

Regards, Frederik.

1

You're more or less already there. Beneath some smaller syntax errors, you made bad use of the anchors of your nodes.

\documentclass[border=10pt,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,fit,shapes,calc}
\tikzset{
    state/.style={
           rectangle,
           rounded corners,
           draw=black, very thick,
           minimum height=2em,
           inner sep=2pt,
           text centered,
           },
}

\tikzstyle{line} = [draw, -latex]

\pgfdeclarelayer{bg}    % declare background layer
\pgfsetlayers{bg,main}

\begin{document}


\tikzset{
    block/.style={draw, fill=white, rectangle, rounded corners, 
            minimum height=2em, minimum width=10em},
    block2/.style={draw, fill=white, rectangle, rounded corners, 
            minimum height=2em, minimum width=10em},  
    block3/.style={draw, fill=white, rectangle, 
            minimum height=4em, minimum width=30em},             
}

\begin{tikzpicture}[auto, node distance=2.5cm, >=latex]

\node[block3] (kronos) {Kronos};
\node[block, above left = 3em of kronos, anchor=south west] (interbank) {Interbank};
\node[block, above right = 3em of kronos, anchor=south east] (pengepolitik) {Pengepolitiske operationer};

\node[block, below = 3em of kronos] (sum) {Sum-, intraday- og Straksclearing};
\node[block, left = 3em of sum] (scp) {SCP};
\node[block, left = 3em of scp] (vp) {VP};

\node[block, right = 3em of sum] (euro) {EuroCCP};
\node[block, right = 3em of euro] (cls) {CLS}; 

\node[block, below = 3em of vp] (valuta) {Valutahandler};
\node[block, below = 3em of scp] (detail) {Detailhandler};
\node[block, below = 3em of cls] (værdi) {Værdipapirhandler};

\draw[dotted,thick] ($(interbank.north west)+(-0.3,0.3)$) rectangle ($(pengepolitik.south east)+(0.3,-0.3)$);

\draw[dotted,thick] ($(vp.north west)+(-0.3,0.3)$) rectangle ($(cls.south east)+(0.3,-0.3)$);

\path[line] (pengepolitik) -- (kronos);
\path[line] (interbank) -- (kronos);
\path[line] (scp) -- (kronos);
\path[line] (euro) -- (kronos);
\path[line] (vp) -- (kronos);
\path[line] (cls) -- (kronos);

\begin{pgfonlayer}{bg}    % select the background layer
       \draw[dashed] ($(kronos.west)+(-6,0)$) -- ($(kronos.east)+(6,0)$);
    \end{pgfonlayer}

\end{tikzpicture}

\end{document}

enter image description here

| improve this answer | |

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.