How do I draw a tree-like figure similar to the one below please?
2 Answers
With some ideas coming from this question, you can obtain such a structure like this:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[
sibling distance = 10em,
every node/.style = {%
shape = rectangle,
align = center,
draw
},
edge from parent fork down
]
\node {Main Tree}
child {node {Sub-tree 1\\{\scriptsize Some text}}}
child {node {Sub-tree 2\\{\scriptsize Some text}}}
child {node {Sub-tree 3\\{\scriptsize Some text}}};
\end{tikzpicture}
\end{document}
You can adapt the distance between the nodes at the same level by changing the value of the sibling distance
option and you can also change the distance between two levels by adding a level distance
option.
Finally, you can change the way your nodes are display by adding to the every node
style.
For more, you can refer to the PGF/TikZ documentation and more precisely, to the trees
library sections.
With forest
is simple:
\documentclass[margin=3mm]{standalone}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
for tree = {
draw,
text width= 22mm,
text centered,
%
s sep = 3mm,
l sep = 4mm,
forked edge,
fork sep=2mm
}
[Main Tree
[Sub-tree 1\\ \scriptsize Some text]
[Sub-tree 2\\ \scriptsize Some text]
[Sub-tree 3\\ \scriptsize Some text]
]
\end{forest}
\end{document}
forest
package should work for example.