TransWikia.com

Arrows are shifted left tikz

TeX - LaTeX Asked by johnny_1010 on March 25, 2021

I am having some issues recreating these Work breakdown structure. I have seen one similar example from TeXample.net (here source), but I am still not getting the exact thing like in the picture below.

The arrow is still shifted, even after I adjusted the shifted left and right.

Here my ideas:

documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows,shapes,positioning,shadows,trees}

definecolor{box-up}{HTML}{ffe6cc}
definecolor{box-down}{HTML}{dae8fe}


tikzset{
    basic/.style  = {draw, text width=6cm,text height=4mm,rectangle,rounded corners=4pt}, 
    root/.style   = {basic, thin, align=center, fill=box-up!90, double=box-up},
    level 1/.style={sibling distance=80mm,text width=6cm, text height=5mm},
    level 2/.style = {basic, thin,align=center, fill=box-up!70, text width=8em},
    level 3/.style = {basic, thin, align=center, fill=box-up!50, text width=7em}
}


begin{document}
begin{tikzpicture}[
align=center,
edge from parent fork down,
edge from parent/.style={->,draw},
>=latex]

node[root] {Header}
child {node[level 2] (c1) {Element 1}}
child {node[level 2] (c2) {Element 2}};

begin{scope}[
anchor = south,
every node/.style={level 3},
edge from parent fork down
]

node [below right of = c1, yshift=-5pt, xshift=5pt] (c11) {Element 11};
%node [below left of = c1] (c12) {Element 12};


node [below of = c2, xshift=15pt] (c21) {Element 21};
node [below of = c21] (c22) {Element 22};
node [below of = c22] (c23) {Element 23};
node [below of = c23] (c24) {Element 24};


end{scope}

% lines from each level 1 node to every one of its "children"

draw[->] (c1.195) |- (c11.west);
%draw[->] (c1.195) |- (c12.west);



draw[->] (c2.195) |- (c21.west);
draw[->] (c2.195) |- (c22.west);
draw[->] (c2.195) |- (c23.west);
draw[->] (c2.195) |- (c24.west);

end{tikzpicture}

end{document}

I put everything south, but the arrows are pointing left. How can I do this exactly?

Here what it should look like:
enter image description here

One Answer

enter image description here

added -- rounded corners at root level

edited correct syntax is below=of... and not below of=...

edited code for south anchor at level 1

you may like to see the following tree -- https://texample.net/tikz/examples/family-tree/

documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows,shapes,positioning,shadows,trees}

definecolor{box-up}{HTML}{ffe6cc}
definecolor{box-down}{HTML}{dae8fe}


tikzset{
    basic/.style  = {draw, text width=6cm,text height=4mm,rectangle,rounded corners=4pt}, 
    root/.style   = {basic, thin, align=center, fill=box-up!90, double=box-up},
    level 1/.style= {sibling distance=80mm,text width=6cm, text height=5mm},
    level 2/.style = {basic, thin,align=center, fill=box-up!70, text width=8em},
    level 3/.style = {basic, thin, align=center, fill=box-up!50, text width=7em}
}


begin{document}
begin{tikzpicture}[
align=center,
edge from parent fork down,
edge from parent/.style={->,draw, rounded corners},
>=latex]

node[root] {Header}
child {node[level 2] (c1) {Element 1}}
child {node[level 2] (c2) {Element 2}};

begin{scope}[
anchor = south,
every node/.style={level 3},
edge from parent fork down
]

node [below right=1em and -3em of c1] (c11) {Element 11};
%node [below left of = c1] (c12) {Element 12};


node [below right=1em and -3em of c2] (c21) {Element 21};
node [below of = c21] (c22) {Element 22};
node [below of = c22] (c23) {Element 23};
node [below of = c23] (c24) {Element 24};
end{scope}

% lines from each level 1 node to every one of its "children"
draw[->] (c1.south) |- (c11.west);
draw[->] (c2.south) |- (c21.west);
draw[->] (c2.south) |- (c22.west);
draw[->] (c2.south) |- (c23.west);
draw[->] (c2.south) |- (c24.west);

end{tikzpicture}

end{document}

Answered by js bibra on March 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP