6

I manged to draw this diagram with tikz:

enter image description here with this code:

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\pagestyle{empty}

\tikzstyle{line} = [draw, -latex']
\tikzstyle{block} = [rectangle, draw, fill=blue!20, 
    text width=5em, text centered, rounded corners, minimum height=4em]


\begin{tikzpicture}[node distance = 5cm, scale=0.1]
    % Place nodes
    \node  [block](trr) {Node};
    \node  [block] (trr1) [below of=trr] {A};
    \node  [block] (trr2) [left of=trr1] {B};    
    \node  [block] (trr3) [right of=trr1] {C};      
    %\node  [block] (trr4) [right of=trr3] {D};        
    % Draw edges
    \path [line] (trr) -- (trr1);
    \path [line] (trr) -- (trr2);
    \path [line] (trr) -- (trr3);
    %\path [line] (trr) -- (trr4);
\end{tikzpicture}


\end{document}

I would like that the block Node remains centered, and that I have 4 elements (A,B,C and D) in the second row. How can I achieve this?

Uncommenting the line

\node  [block] (trr4) [right of=trr3] {D};

and

\path [line] (trr) -- (trr4);  

results in enter image description here

4

You actually draw a tree .. so see if code below gives desired result:

enter image description here

\documentclass[border=3mm,
               tikz]{standalone}

\usepackage[latin1]{inputenc}
\usepackage{tikz}

\usetikzlibrary{arrows}

    \begin{document}
\begin{tikzpicture}[
every node/.style = {rectangle, draw, rounded corners, 
                     fill=blue!20,
                     text width=3em, minimum height=2em, 
                     align=center},
edge from parent/.style= {draw, -latex'}
                        ]
\node (trr) {Node}
    child {node (trr1) {A}}
    child {node (trr2) {B}}
    child {node (trr3) {C}}
    child {node (trr4) {D}};
\end{tikzpicture}
    \end{document}

Addendum: After five (!) years I notice, that you like to have arrow at child ends on north of nodes. Using forest package this can be simply to o achieve:

\documentclass[border=3mm]{standalone}
\usepackage{forest}
\usetikzlibrary{arrows.meta}

\begin{document}
    \begin{forest}
for tree = {
% nodes
    draw, rounded corners, fill=blue!20,
    text width=3em, minimum height=2em, text centered,
% tree
    child anchor = north,
    edge={-Latex},
    l sep=11mm,
    s sep=1mm
            }
[Node
    [A] [B] [C] [D]
]
    \end{forest}
\end{document}

enter image description here

3
  • Thank you perfect!! I don't even have to specify the edges now. Do you know if its easy to tell that the arrow of each edge should be at the center of the child( so for instance that the left arrow is above A).
    – Adam
    Mar 18 '16 at 15:52
  • @Adam, I'm very sorry but I only noticed your note now (after five years!)
    – Zarko
    Mar 1 at 17:10
  • haha no worries, my times with Latex are over ;)
    – Adam
    Mar 1 at 18:01

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.