1

First of all, I want to thank the community for the help I obtained in my first question, some days ago. Having said that, I want to ask you for some help again, if I may. Essentially, I am currently using the powerful package Forest to draw Game Theory trees and, so far, so good. But now, I am faced with something that I do not know how to do and that is not explained in the (rather complex) manual of the Forest package. Essentially, I have a game (tree) with three nodes, each node being the beginning of a sub-game. I basically need to make clear that there are three sub-games in the tree. The graphical representation of what I am looking for is something like this: enter image description here

The tree that I have drawn looks like this one (and I would like to keep it): enter image description here

In a nutshell, I would like to draw the red squares of the first tree (Picture 1) on my tree (Picture 2). However, I probably need rhombus, given the form of my tree. Finally, I provide you with the code I am currently using for my tree:

\begin{center}
\begin{forest} for tree={l sep=4em, s sep=8em, anchor=center}
[$P_1$, circle, draw,
    [{2, 2}, edge label={node[midway,left]{$D$}}]
    [$P_2$, edge label={node[midway,right]{$A$}}, circle, draw, 
        [{1, 1}, edge label={node[midway,left]{$d$}}] 
        [$P_1$, edge label={node[midway,right]{$a$}}, circle, draw,
            [{0, 0}, edge label={node[midway,left]{$D$}}]
            [{3, 3}, edge label={node[midway,right]{$A$}}]]]]
\node[above=30pt,align=center,anchor=center] {\textbf{Figure IV.} Extensive Form of a Centipede Game Variant};
\end{forest}
\end{center}

What do I need to add/change to include these squares?

Thank you all in advance.

Best Regards, Héctor.

5
  • 2
    Related: tex.stackexchange.com/a/233767/1952
    – Ignasi
    Commented Feb 10, 2016 at 16:56
  • 1
    @Ignasi That's very related (kind of a duplicate, I'd say).
    – Alenanno
    Commented Feb 10, 2016 at 17:04
  • Thank you both. I have been searching, but I did not come up with that one. If this is duplicate, how can I delete this question, then?
    – EoDmnFOr3q
    Commented Feb 10, 2016 at 17:18
  • 1
    Well, it may not be a duplicate if you want a rhombus.
    – cfr
    Commented Feb 11, 2016 at 3:01
  • I have finally managed to draw the squares. I also figured out how to rotate them 45º, but they look awful because the branches of the tree do not form 45º angles. I have also tried your solution and it works nicely.
    – EoDmnFOr3q
    Commented Feb 11, 2016 at 8:00

2 Answers 2

3

Not exactly a rhombus, but you can modify the angles and distances if that matters.

\documentclass[tikz, border=10pt, multi]{standalone}
\usepackage{forest}
\usetikzlibrary{shapes.geometric,fit}
\begin{document}
\begin{forest}
  /tikz/my edge label/.style={inner sep=5pt, midway},
  /tikz/rhombus/.style={trapezium, trapezium left angle=105, trapezium right angle=75, draw=red},
  my rhombus/.style n args=2{
    tikz={\node [fit=#1, rhombus, inner sep=#2] {};},
  },
  for tree={
    l sep=4em,
    s sep=11em,
    anchor=center,
    fit=rectangle,
    calign=fixed edge angles,
    before typesetting nodes={
      if n'=1{
        edge label/.wrap value={\noexpand node [my edge label,right] {$#1$} }
      }{
        edge label/.wrap value={\noexpand node [my edge label,left] {$#1$} }
      },
    },
    if n children=0{}{
      circle,
      draw,
    }
  }
  [$P_1$, my rhombus={() (current bounding box.west) (current bounding box.south east)}{12.5pt}
    [{2, 2}, edge label=D]
    [$P_2$, edge label=A, my rhombus={() (!1) (!2 2)}{7.5pt}
      [{1, 1}, edge label=d]
      [$P_1$, edge label=a, my rhombus={() (!1) (!2)}{2.5pt}
        [{0, 0}, edge label=D]
        [{3, 3}, edge label=A]
      ]
    ]
  ]
\end{forest}
\end{document}

non-rhombus

1
  • Thank you very much! This works nicely and it is a good alternative to the simple squares.
    – EoDmnFOr3q
    Commented Feb 11, 2016 at 8:00
5

A solution to use the istgame package:

enter image description here

\documentclass{standalone}

\usepackage{istgame}

\begin{document}    
\begin{istgame}[font=\footnotesize]
\xtdistance{15mm}{25mm}
\istrooto(0){$P_1$}
  \istb{D}[l]{2,2}
  \istb{A}[r]
  \endist
\istrooto(1)(0-2){$P_2$}
  \istb{d}[l]{1,1}
  \istb{a}[r]
  \endist
\istrooto(2)(1-2){$P_1$}
  \istb{D}[l]{0,0}
  \istb{A}[r]{3,3}
  \endist
\xtSubgameBox(0){(0-1)(2-2)}
\xtSubgameBox(1){(1-1)(2-2)}[inner sep=18pt]
\xtSubgameBox(2){(2-1)(2-2)}[inner sep=16pt]
%\xtSubgameBox(2){(2-1)(2-2)}[solid,rounded corners=0pt,inner sep=16pt]
\end{istgame}

\end{document}

It is your choice whether to add options like [solid,rounded corners=0pt] or color.

2
  • 1
    I think the OP wanted a rhombus. I didn't exactly get rhombuses, but yours are definitely rectangles!
    – cfr
    Commented Dec 16, 2017 at 16:54
  • You are right. I missed the 'rhombus' part.
    – I. Cho
    Commented Dec 18, 2017 at 1:43

You must log in to answer this question.

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