1

How can I draw this tree diagram in LaTex? enter image description here

closed as too broad by Werner, dexteritas, Stefan Pinnow, Raaja, Phelype Oleinik Mar 6 at 21:00

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Try looking here to get started. When you post a question, please provide a "Minimal Working Example" (MWE) that starts with \documentclass, includes all relevant \usepackage commands, ends with \end{document} and compiles without errors, even if it does not produce your desired output. Welcome to TeX.SX. – Sandy G Mar 6 at 17:53
  • 2
    It can be done using TikZ something like this:texample.net/tikz/examples/tree . You need to try to do it, and then ask if you have any problems. – hpekristiansen Mar 6 at 17:54
3

Welcome to TeX-SE! This is to give you a start. I am convinced that you could also add the H and T programmatically, but I do not have motivation now to spell this out (the more so since I am not sure if that's what you want).

\documentclass{article} 
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{forest}
for tree={s sep=0cm,l sep=1.2cm,font=\sffamily,
where n children=0{rotate=90,anchor=west,edge={thick,-{Latex}}}{},
edge={thick}
}
  [H,alias=L1
   [H,alias=L2
    [H,alias=L3
     [H,alias=L4
      [H,alias=L5
       [HHHHH,alias=L6]
      ]
      [T
       [HHHHT]
      ]
     ]
     [T
      [H
       [HHHTH]
      ]
      [T
       [HHHTT]
      ]
     ]
    ]
    [T
     [H
      [H
       [HHTHH]
      ]
      [T
       [HHTHT]
      ]
     ]
     [T
      [H
       [HHTTH]
      ]
      [T
       [HHTTT]
      ]
     ]
    ]
   ]
   [T
    [H
     [H
      [H
       [HTHHH]
      ]
      [T
       [HTHHT]
      ]
     ]
     [T
      [H
       [HTHTH]
      ]
      [T
       [HTHTT]
      ]
     ]
    ]
    [T
     [H
      [H
       [HTTHH]
      ]
      [T
       [HTTHT]
      ]
     ]
     [T
      [H
       [HTTTH]
      ]
      [T
       [HTTTT]
      ]
     ]
    ]
   ]
  ]
\foreach \X [count=\Y] in {First,Second,Third,Fourth,Fifth} 
{\node[anchor=east,font=\sffamily] at (L6.north|-L\Y){\X\ flip};} 
\node[anchor=east,font=\sffamily] at (L6.north){Outcome}; 
\end{forest}
\end{document}

enter image description here

*NOTE**: Almost everything I know about forest I learned from some answers by cfr, who really is a forest master. If you consider upvoting this, please upvote some answer(s) by her instead. That way you will certainly cast a deserved upvote.

\documentclass{article} 
\usepackage{adjustbox}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{adjustbox}{valign=t,width=0.5\textwidth}
\begin{forest}
for tree={s sep=0cm,l sep=1.2cm,font=\sffamily,
where n children=1{rotate=90,anchor=west,edge={thick,-{Latex}}}{},
edge={thick}
}
  [H,alias=L1
   [H,alias=L2
    [H,alias=L3
     [H,alias=L4
      [H,alias=L5
       [HHHHH,alias=L6
        [$5$,alias=L7]
       ]
      ]
      [T
       [HHHHT
        [$3$]
       ]
      ]
     ]
     [T
      [H
       [HHHTH
       [$3$]
       ]
      ]
      [T
       [HHHTT
        [$1$]
       ]
      ]
     ]
    ]
    [T
     [H
      [H
       [HHTHH
        [$3$]
       ]
      ]
      [T
       [HHTHT
        [$1$]
       ]
      ]
     ]
     [T
      [H
       [HHTTH
        [$1$]
       ]
      ]
      [T
       [HHTTT
        [$-1$]
       ]
      ]
     ]
    ]
   ]
   [T
    [H
     [H
      [H
       [HTHHH
        [$3$]
       ]
      ]
      [T
       [HTHHT
        [$1$]
       ]
      ]
     ]
     [T
      [H
       [HTHTH
        [$1$]
       ]
      ]
      [T
       [HTHTT
        [$-1$]
       ]
      ]
     ]
    ]
    [T
     [H
      [H
       [HTTHH
        [$1$]
       ]
      ]
      [T
       [HTTHT
        [$-1$]
       ]
      ]
     ]
     [T
      [H
       [HTTTH
        [$-1$]
       ]
      ]
      [T
       [HTTTT
        [$-3$]
       ]
      ]
     ]
    ]
   ]
  ]
\foreach \X [count=\Y] in {First,Second,Third,Fourth,Fifth} 
{\node[anchor=east,font=\sffamily] at (L6.north|-L\Y){\X\ flip};} 
\node[anchor=east,font=\sffamily] at (L6.north){Outcome}; 
\node[anchor=east,font=\sffamily] at (L7.west){Lands on}; 
\end{forest}
\end{adjustbox}
\begin{adjustbox}{valign=t,width=0.47\textwidth}
\begin{forest}
for tree={s sep=0cm,l sep=1.2cm,font=\sffamily,
where n children=1{rotate=90,anchor=west,edge={thick,-{Latex}}}{},
edge={thick}
}
  [T,alias=L1
   [H,alias=L2
    [H,alias=L3
     [H,alias=L4
      [H,alias=L5
       [THHHH,alias=L6
        [$3$,alias=L7]
       ]
      ]
      [T
       [THHHT
        [$1$]
       ]
      ]
     ]
     [T
      [H
       [THHTH
       [$1$]
       ]
      ]
      [T
       [THHTT
        [$-1$]
       ]
      ]
     ]
    ]
    [T
     [H
      [H
       [THTHH
        [$1$]
       ]
      ]
      [T
       [THTHT
        [$-1$]
       ]
      ]
     ]
     [T
      [H
       [THTTH
        [$-1$]
       ]
      ]
      [T
       [THTTT
        [$-3$]
       ]
      ]
     ]
    ]
   ]
   [T
    [H
     [H
      [H
       [TTHHH
        [$1$]
       ]
      ]
      [T
       [TTHHT
        [$-1$]
       ]
      ]
     ]
     [T
      [H
       [TTHTH
        [$-1$]
       ]
      ]
      [T
       [TTHTT
        [$-3$]
       ]
      ]
     ]
    ]
    [T
     [H
      [H
       [TTTHH
        [$-1$]
       ]
      ]
      [T
       [TTTHT
        [$-3$]
       ]
      ]
     ]
     [T
      [H
       [TTTTH
        [$-3$]
       ]
      ]
      [T
       [TTTTT
        [$-5$]
       ]
      ]
     ]
    ]
   ]
  ]
\end{forest}
\end{adjustbox}
\end{document}

enter image description here

  • @KJO You are right, thanks! I just removed it. Thanks! – marmot Mar 7 at 0:44
  • Thanks a lot!! It's really helpful! Can I ask you one more question? How can I produce one more line:Lands on: 5 3 3 1 3 1 1 -1 3 1 1 -1 1 -1 -1 -3? And Is that possible to put graph for H and graph for T side by side? – Karena Mar 7 at 10:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.