Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following figure:

Game tree

As of now I create this in Word/Powerpoint and paste the screenshot in a LaTeX file. Is there a way to create this natively? Also, what would be the advantage of doing so?

The tables are just place holders and actual table design/content may change. But I prefer if it could be editable and not fixed. I'm not sure I even know where to start or how to go about it. I've never needed to draw anything in LaTeX before.

share|improve this question
    
Please note that the tables would look much better without vertical lines. I would also drop the top and bottom horizontal ones. (Alternatively, you might try keeping only the second vertical and horizontal lines, those between the row and column headers and their contents - I didn't try this at home, it's almost 2:00 am here;), but I guess it might look ok.) –  mbork Mar 2 at 0:52

3 Answers 3

up vote 15 down vote accepted

Using forest:

\documentclass{article}
\usepackage{forest}

\newcommand\mytable[5]{%
#1\\
\begin{tabular}[t]{*{3}{|c}|}
\hline
& T1 & T2 \\
\hline
T1 & #2 & #3 \\
\hline
T2 & #4 & #5 \\
\hline
\end{tabular}%
}

\begin{document}
\begin{forest}
for tree={parent anchor=south, child anchor=north,l=2cm,edge={->}},
for descendants={text width=4.2cm,align=c}
[Developers
  [\mytable{Type I probability: 0.2}{A,B}{C,D}{E,F}{G,H}]
  [\mytable{Type II probability: 0.5}{P,Q}{R,S}{U,V}{W,X}]
  [\mytable{Type III probability: 0.3}{A,B}{C,D}{E,F}{G,H}]
]
\end{forest}

\end{document}

enter image description here

As mbork notices in his comment, perhaps you can avoid most of the lines in the tables:

\documentclass{article}
\usepackage{forest}

\newcommand\mytable[5]{%
#1\\[1ex]
{%
\renewcommand\arraystretch{1.3}%
\begin{tabular}[t]{c|cc}
& T1 & T2 \\
\hline
T1 & #2 & #3 \\
T2 & #4 & #5 \\
\end{tabular}%
}%
}

\begin{document}
\begin{forest}
for tree={parent anchor=south, child anchor=north,l=2cm,edge={->}},
for descendants={text width=4.2cm,align=c}
[Developers
  [\mytable{Type I probability: 0.2}{A,B}{C,D}{E,F}{G,H}]
  [\mytable{Type II probability: 0.5}{P,Q}{R,S}{U,V}{W,X}]
  [\mytable{Type III probability: 0.3}{A,B}{C,D}{E,F}{G,H}]
]
\end{forest}

\end{document}

enter image description here

share|improve this answer
1  
Any way to get the middle line straight and along with arrowheads? –  PhD Mar 2 at 0:04
    
@JPi forest uses TikZ. –  Gonzalo Medina Mar 2 at 0:10
    
@PhD arrow tips added. –  Gonzalo Medina Mar 2 at 0:11
    
@PhD Initially I overlooked the other requirement, now I've added the options to my answer. –  Gonzalo Medina Mar 2 at 0:38
    
Great!!! Thanks a ton! Learnt something new today! –  PhD Mar 2 at 7:17

Same as cmhughes answer but with fine adjustments.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
  \node (a) at (0,0) {Developers};
  \node[below left=3cm and 4cm of a,align=center,anchor=east] (b) {%
             Type I: Probability = 0.2\\
             \begin{tabular}{|c|c|c|}\hline
                & 2 & 3 \\\hline
             4 & 5 & 6 \\\hline
             7 & 8 & 9 \\\hline
             \end{tabular}
             };
  \node[below=3cm of a,align=center,anchor=center] (c) {%
             Type I: Probability = 0.5\\
             \begin{tabular}{|c|c|c|}\hline
                & 2 & 3 \\\hline
             4 & 5 & 6 \\\hline
             7 & 8 & 9 \\\hline
             \end{tabular}
             };
  \node[below right=3cm and 4cm of a,align=center,anchor=west] (d) {%
             Type I: Probability = 0.3\\
             \begin{tabular}{|c|c|c|}\hline
                & 2 & 3 \\\hline
             4 & 5 & 6 \\\hline
             7 & 8 & 9 \\\hline
             \end{tabular}
             };
    \draw[->] (a.south)--(b.north);
    \draw[->] (a.south)--(c.north);
    \draw[->] (a.south)--(d.north);

\end{tikzpicture}
\end{document}

enter image description here

Adjust the positioning (by changing 3cm and 4cm) depending upon the content and size of the table.

share|improve this answer

You have quite a few options for this- the tikz package is very powerful and can be used in a variety of different ways.

In the code below I have used the positioning library.

screenshot

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
    \node (developers){Developers};
    \node (probI)[below left=of developers,align=center]{Type I: Probability\\
        \begin{tabular}{ccc}
            1 & 2 & 3 \\
            1 & 2 & 3 \\
        \end{tabular}
    };
    \node (probII)[below =of developers,align=center]{Type II: Probability\\
        \begin{tabular}{ccc}
            1 & 2 & 3 \\
            1 & 2 & 3 \\
        \end{tabular}
    };
    \node (probIII)[below right=of developers,align=center]{Type III: Probability\\
        \begin{tabular}{ccc}
            1 & 2 & 3 \\
            1 & 2 & 3 \\
        \end{tabular}
    };
    % draw the connections
    \draw[->] (developers)--(probI);
    \draw[->] (developers)--(probII);
    \draw[->] (developers)--(probIII);
\end{tikzpicture}
\end{document}

You can adjust the placement of the arrows by using, for example,

\draw[->] (developers)--(probI.north);
\draw[->] (developers)--(probII);
\draw[->] (developers)--(probIII.north);

which gives

screenshot

Or else

\draw[->] (developers.south)--(probI.north);
\draw[->] (developers.south)--(probII);
\draw[->] (developers.south)--(probIII.north);

which gives

screenshot

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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