1

I need to make a binary tree

How can I see such tree in my document? I've got margins

\usepackage{geometry} 
\geometry{top=25mm} 
\geometry{bottom=35mm} 
\geometry{left=35mm} 
\geometry{right=20mm}
1
  • Welcome to TeX.SX! You've already tagged this question with {tikz-pgf}. What specifically do you have problem with? What have your tried so far? In its current form this question seems like a duplicate of various tree questions on this ite, e.g. Unbalanced binary tree with forest.
    – siracusa
    Oct 10, 2019 at 5:49

1 Answer 1

2

Welcome! With forest, which is based on TikZ, this is straightforward. You need to replace X,Y,Z by your numbers.

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={parent anchor=south}
 [{$(1,1,1)$}
  [{$(2,1,1)$}
   [{$(2,5,1)$}
    [{$(13,1,5)$}
     [{$(X,Y,Z)$}
      [{$(X,Y,Z)$}
      ]
      [{$(X,Y,Z)$}
      ]
     ]
     [{$(X,Y,Z)$}
      [{$(X,Y,Z)$}
      ]
      [{$(X,Y,Z)$}
      ]
     ]
    ]
    [{$(2,5,29)$}
     [{$(X,Y,Z)$}
      [{$(X,Y,Z)$}
      ]
      [{$(X,Y,Z)$}
      ]
     ]
     [{$(X,Y,Z)$}
      [{$(X,Y,Z)$}
      ]
      [{$(X,Y,Z)$}
      ]
     ]
    ]
   ]
  ]
 ]
\end{forest}
\end{document}

enter image description here

3
  • 2
    Since all the nodes are math, you might as well add math content as an option and ditch all the $.
    – Alan Munn
    Oct 10, 2019 at 6:04
  • How I can change the size, cause I've such margins \usepackage{geometry} \geometry{top=25mm} \geometry{bottom=35mm} \geometry{left=35mm} \geometry{right=20mm} Oct 10, 2019 at 13:55
  • @RuslanNevretdinov The current tree fits in such a document, but it won't fir if one adds all the numbers you have. Then the options include making the font smaller, decreasing the distances between siblings or using something like adjustbox to make the tree fit.
    – user194703
    Oct 10, 2019 at 14:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .