I am trying to create a LCM tree diagram which looks something like this:


Also what is the code to draw circles around numbers?

  • Welcome to TeX.sx!
    – rtzll
    Jan 27, 2013 at 18:09
  • Thank you all from the bottom of my heart! I know my students will appreciate these worksheets that you guys helped designed Jan 30, 2013 at 10:14

3 Answers 3


With my tikz-based package forest, this can be achieved in a very concise way:


\begin{forest} mark/.style={circle,draw=red}
  • 2
    +1 This forest package looks like serious business!...
    – Count Zero
    Jan 27, 2013 at 21:06
  • @CountZero tnx! it did take a serious amount of time to write it ... :-) Jan 27, 2013 at 21:35
  • 1
    Congratulations and a big thank you for you contribution. Can you please add your details in here meta.tex.stackexchange.com/questions/1181/… ? You can use the proper icon for the dev-page.
    – percusse
    Jan 27, 2013 at 22:25
  • Thanks. Added --- great idea having such a page! I didn't use the icon since forest-styles is only a style repository. Jan 28, 2013 at 0:27
  • @SašoŽivanović forest is indeed a very nice package. I'm wondering why you decided not to use the qtree .label syntax for node labels. I've got lots of legacy trees, so that switching to forest would take some effort. Would it be possible to support both styles?
    – Alan Munn
    Jan 28, 2013 at 0:41

Tikz can do nice trees:



    \node {8} 
    child { node[circle,draw=red] {2} }
    child { node {4} 
      child { node[circle,draw=red] {2} }
      child { node[circle,draw=red] {2} }


Just to add the obligatory tikz-qtree solution:

\Tree [.8 [.\node[Red] (A){2}; ]
            [.\node [Red] (B) {2}; ]
            [.\node [Red] (C) {2};]]]

output of code

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.