Making tree structure using tikz












2















I want to make a tree structure by tikz. I am not a professional latex user and I am just trying to combine examples to make it work but first I would like that the edges have direction and then T 3 and T 4 overlap and then I would like to be able to make the space between nodes in each layer being more flexible to change. This in my code:



documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


There is a circle created on the edges between char 1 and script 1. I can not figure why? Any suggestion would be appreciate!!










share|improve this question























  • Also, there are many packages, which allow you to construct trees which are easier to use.

    – Viktor Glombik
    5 hours ago











  • @ViktorGlombik If you are referring to forest, I agree, but giving a list of packages you have in mind might help here.

    – marmot
    4 hours ago
















2















I want to make a tree structure by tikz. I am not a professional latex user and I am just trying to combine examples to make it work but first I would like that the edges have direction and then T 3 and T 4 overlap and then I would like to be able to make the space between nodes in each layer being more flexible to change. This in my code:



documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


There is a circle created on the edges between char 1 and script 1. I can not figure why? Any suggestion would be appreciate!!










share|improve this question























  • Also, there are many packages, which allow you to construct trees which are easier to use.

    – Viktor Glombik
    5 hours ago











  • @ViktorGlombik If you are referring to forest, I agree, but giving a list of packages you have in mind might help here.

    – marmot
    4 hours ago














2












2








2








I want to make a tree structure by tikz. I am not a professional latex user and I am just trying to combine examples to make it work but first I would like that the edges have direction and then T 3 and T 4 overlap and then I would like to be able to make the space between nodes in each layer being more flexible to change. This in my code:



documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


There is a circle created on the edges between char 1 and script 1. I can not figure why? Any suggestion would be appreciate!!










share|improve this question














I want to make a tree structure by tikz. I am not a professional latex user and I am just trying to combine examples to make it work but first I would like that the edges have direction and then T 3 and T 4 overlap and then I would like to be able to make the space between nodes in each layer being more flexible to change. This in my code:



documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


There is a circle created on the edges between char 1 and script 1. I can not figure why? Any suggestion would be appreciate!!







tikz-pgf tikz-trees graphs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 5 hours ago









DalekDalek

21917




21917













  • Also, there are many packages, which allow you to construct trees which are easier to use.

    – Viktor Glombik
    5 hours ago











  • @ViktorGlombik If you are referring to forest, I agree, but giving a list of packages you have in mind might help here.

    – marmot
    4 hours ago



















  • Also, there are many packages, which allow you to construct trees which are easier to use.

    – Viktor Glombik
    5 hours ago











  • @ViktorGlombik If you are referring to forest, I agree, but giving a list of packages you have in mind might help here.

    – marmot
    4 hours ago

















Also, there are many packages, which allow you to construct trees which are easier to use.

– Viktor Glombik
5 hours ago





Also, there are many packages, which allow you to construct trees which are easier to use.

– Viktor Glombik
5 hours ago













@ViktorGlombik If you are referring to forest, I agree, but giving a list of packages you have in mind might help here.

– marmot
4 hours ago





@ViktorGlombik If you are referring to forest, I agree, but giving a list of packages you have in mind might help here.

– marmot
4 hours ago










1 Answer
1






active

oldest

votes


















4















  1. The circles appear because you have node{} in path [line] (s2) -- node {}(ch2);

  2. You can add arrows by saying edge from parent/.style={draw,-latex'}.

  3. You were loading graphdrawing but it is not obvious to me you were using it.


  4. left=2cm of char 1 should probably be left=2cm of ch1.

  5. You can change the dimensions/distances at any level using e.g. level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}.

  6. To debug you may temporarily set opacity=0.5 to better understand where some nodes went.

  7. The rest of your statements I do not understand. Could you perhaps consider making them clearer?




documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}

documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


enter image description here



I am confused by your comments. Something like this?



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}


enter image description here



Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)






share|improve this answer


























  • Thanks for the answer but I still do not see the leave corresponding to T 3. where is it?

    – Dalek
    4 hours ago











  • @Dalek It is where you put it: under T4. You can check this by adding opacity=0.5 to the options of begin{tikzpicture}. May I ask where you want to have it?

    – marmot
    4 hours ago











  • but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?

    – Dalek
    4 hours ago











  • @Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)

    – marmot
    4 hours ago













  • @mamot Thanks. Is it possible in the case of shared lower level node, both the higher level char1 and char2 be connected to the same node for instance, T2 instead of having two nodes?

    – Dalek
    4 hours ago













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473550%2fmaking-tree-structure-using-tikz%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4















  1. The circles appear because you have node{} in path [line] (s2) -- node {}(ch2);

  2. You can add arrows by saying edge from parent/.style={draw,-latex'}.

  3. You were loading graphdrawing but it is not obvious to me you were using it.


  4. left=2cm of char 1 should probably be left=2cm of ch1.

  5. You can change the dimensions/distances at any level using e.g. level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}.

  6. To debug you may temporarily set opacity=0.5 to better understand where some nodes went.

  7. The rest of your statements I do not understand. Could you perhaps consider making them clearer?




documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}

documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


enter image description here



I am confused by your comments. Something like this?



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}


enter image description here



Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)






share|improve this answer


























  • Thanks for the answer but I still do not see the leave corresponding to T 3. where is it?

    – Dalek
    4 hours ago











  • @Dalek It is where you put it: under T4. You can check this by adding opacity=0.5 to the options of begin{tikzpicture}. May I ask where you want to have it?

    – marmot
    4 hours ago











  • but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?

    – Dalek
    4 hours ago











  • @Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)

    – marmot
    4 hours ago













  • @mamot Thanks. Is it possible in the case of shared lower level node, both the higher level char1 and char2 be connected to the same node for instance, T2 instead of having two nodes?

    – Dalek
    4 hours ago


















4















  1. The circles appear because you have node{} in path [line] (s2) -- node {}(ch2);

  2. You can add arrows by saying edge from parent/.style={draw,-latex'}.

  3. You were loading graphdrawing but it is not obvious to me you were using it.


  4. left=2cm of char 1 should probably be left=2cm of ch1.

  5. You can change the dimensions/distances at any level using e.g. level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}.

  6. To debug you may temporarily set opacity=0.5 to better understand where some nodes went.

  7. The rest of your statements I do not understand. Could you perhaps consider making them clearer?




documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}

documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


enter image description here



I am confused by your comments. Something like this?



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}


enter image description here



Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)






share|improve this answer


























  • Thanks for the answer but I still do not see the leave corresponding to T 3. where is it?

    – Dalek
    4 hours ago











  • @Dalek It is where you put it: under T4. You can check this by adding opacity=0.5 to the options of begin{tikzpicture}. May I ask where you want to have it?

    – marmot
    4 hours ago











  • but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?

    – Dalek
    4 hours ago











  • @Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)

    – marmot
    4 hours ago













  • @mamot Thanks. Is it possible in the case of shared lower level node, both the higher level char1 and char2 be connected to the same node for instance, T2 instead of having two nodes?

    – Dalek
    4 hours ago
















4












4








4








  1. The circles appear because you have node{} in path [line] (s2) -- node {}(ch2);

  2. You can add arrows by saying edge from parent/.style={draw,-latex'}.

  3. You were loading graphdrawing but it is not obvious to me you were using it.


  4. left=2cm of char 1 should probably be left=2cm of ch1.

  5. You can change the dimensions/distances at any level using e.g. level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}.

  6. To debug you may temporarily set opacity=0.5 to better understand where some nodes went.

  7. The rest of your statements I do not understand. Could you perhaps consider making them clearer?




documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}

documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


enter image description here



I am confused by your comments. Something like this?



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}


enter image description here



Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)






share|improve this answer
















  1. The circles appear because you have node{} in path [line] (s2) -- node {}(ch2);

  2. You can add arrows by saying edge from parent/.style={draw,-latex'}.

  3. You were loading graphdrawing but it is not obvious to me you were using it.


  4. left=2cm of char 1 should probably be left=2cm of ch1.

  5. You can change the dimensions/distances at any level using e.g. level 1/.style={sibling distance=50mm},level 2/.style={sibling distance=15mm},level 3/.style={text width=1cm,font=tiny}.

  6. To debug you may temporarily set opacity=0.5 to better understand where some nodes went.

  7. The rest of your statements I do not understand. Could you perhaps consider making them clearer?




documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=50mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}

documentclass{article}
usepackage{tikz}
usetikzlibrary{graphdrawing}
usetikzlibrary{shapes,arrows,calc}
usetikzlibrary{graphs}
tikzstyle{line} = [draw, -latex']
begin{document}
begin{tikzpicture}[sibling distance=10em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20}]]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 2}
child { node {comment} } }
child { node {T 3}
child { node {comment} } } node [left=2cm of char 1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of char 2] (s2){script 2}};
%Draw edges
path [line] (s2) -- node {}(ch2);
path [line] (s1) -- node {}(ch1);
end{tikzpicture}

end{document}


enter image description here



I am confused by your comments. Something like this?



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes,arrows,calc,positioning}
usetikzlibrary{graphs}
begin{document}
begin{tikzpicture}[sibling distance=10em,%opacity=0.5,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=white!20},
line/.style={draw, -latex'},
edge from parent/.style={draw,-latex'},
level 1/.style={sibling distance=30mm},
level 2/.style={sibling distance=15mm},
level 3/.style={text width=1cm,font=tiny}]
node {P}
child { node (ch1){char1}
child { node {T 1}
child { node {comment} } }
child { node {T 3}
child { node {comment} } }
child { node {T 2}
child { node {comment} } } node [left=2cm of ch1] (s1){script 1}}
child { node (ch2){char 2}
child { node {T 2}
child { node {comment} } }
child { node {T 4}
child { node {comment} } }
child { node {T 5}
child { node {comment} } } node [right=2cm of ch2] (s2){script 2}};
%Draw edges
path [line] (s2) -- (ch2);
path [line] (s1) -- (ch1);
end{tikzpicture}
end{document}


enter image description here



Note that this is just to clarify your request, and not a proposal for really do this. (And this is not a tree.)







share|improve this answer














share|improve this answer



share|improve this answer








edited 4 hours ago

























answered 5 hours ago









marmotmarmot

97.6k4112215




97.6k4112215













  • Thanks for the answer but I still do not see the leave corresponding to T 3. where is it?

    – Dalek
    4 hours ago











  • @Dalek It is where you put it: under T4. You can check this by adding opacity=0.5 to the options of begin{tikzpicture}. May I ask where you want to have it?

    – marmot
    4 hours ago











  • but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?

    – Dalek
    4 hours ago











  • @Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)

    – marmot
    4 hours ago













  • @mamot Thanks. Is it possible in the case of shared lower level node, both the higher level char1 and char2 be connected to the same node for instance, T2 instead of having two nodes?

    – Dalek
    4 hours ago





















  • Thanks for the answer but I still do not see the leave corresponding to T 3. where is it?

    – Dalek
    4 hours ago











  • @Dalek It is where you put it: under T4. You can check this by adding opacity=0.5 to the options of begin{tikzpicture}. May I ask where you want to have it?

    – marmot
    4 hours ago











  • but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?

    – Dalek
    4 hours ago











  • @Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)

    – marmot
    4 hours ago













  • @mamot Thanks. Is it possible in the case of shared lower level node, both the higher level char1 and char2 be connected to the same node for instance, T2 instead of having two nodes?

    – Dalek
    4 hours ago



















Thanks for the answer but I still do not see the leave corresponding to T 3. where is it?

– Dalek
4 hours ago





Thanks for the answer but I still do not see the leave corresponding to T 3. where is it?

– Dalek
4 hours ago













@Dalek It is where you put it: under T4. You can check this by adding opacity=0.5 to the options of begin{tikzpicture}. May I ask where you want to have it?

– marmot
4 hours ago





@Dalek It is where you put it: under T4. You can check this by adding opacity=0.5 to the options of begin{tikzpicture}. May I ask where you want to have it?

– marmot
4 hours ago













but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?

– Dalek
4 hours ago





but as I said in my question I want to be able to play with the distances of leaves from each other in order to avoid this overlap. How can I include it in my code?

– Dalek
4 hours ago













@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)

– marmot
4 hours ago







@Dalek I edited my answer accordingly. (Your question contains a sentence that runs over four lines, I apologize if I missed some things when trying to parse it.)

– marmot
4 hours ago















@mamot Thanks. Is it possible in the case of shared lower level node, both the higher level char1 and char2 be connected to the same node for instance, T2 instead of having two nodes?

– Dalek
4 hours ago







@mamot Thanks. Is it possible in the case of shared lower level node, both the higher level char1 and char2 be connected to the same node for instance, T2 instead of having two nodes?

– Dalek
4 hours ago




















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473550%2fmaking-tree-structure-using-tikz%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python