0

I've made that tree, but I need to do some improvements and I don't know how. First of all, I want to paint the squares, making them purple, and the letters white. Second, I want to make the arrows purple to. Third,the boxes with the massage "Thanos fica com a joia" in a darker purple and the boxes with the message "Thanos fica sem a joia" in a lighter purple. Last, I need to be able to put the probabilities next to the squares, and I don't know how.

Thank you guys for your help

\usepackage{forest}% for version 1
\begin{document}
\begin{forest}
  for tree={
    grow'=0,
    draw,
    align=c,
    font=\sffamily,
    rounded corners,
    parent anchor=east,
    child anchor=west,
    edge path={%
      \noexpand\path [\forestoption{edge}] (!u.parent anchor) -- ++(5pt,0) |- (.child anchor)\forestoption{edge label};
    }
  },
  highlight/.style={
    thick,
    font=\sffamily\bfseries
  }
  [{Peter Quill \\ rouba a joia}
        [{Kree captura Quill}
        [{Quill foge sem a joia}]
     [{Quill foge com a joia}
        [{Quill tenta vender a joia}
         [{Luta com Ronan}
         [{Vence}
         [{Joia é entregue a Tropa Nova}
         [{Thanos consegue a joia}]
         ]
         [{Quill fica com a joia}
         [{Thanos vence}
         [{Thanos fica com a joia}]
         ]
         [{Quill vence}
         [{Thanos fica sem a joia}]
         ]
         ]
         [{Quill entrega a joia para Youndu}
         [{Youndu vence}
         [{Thanos fica sem a joia}]
         ]
         [{Thanos vence}]
         [{Thanos fica com a joia}]
         ]
         ]
         ]
         [{Perde}
         [{Thanos fica sem a joia}]
         ]
         ]
         [{Quill vende a joia}
         [{Thanos fica sem a joia}]
         ]
         ]
    [{Quill escapa}
      [{Quill fica com a joia}
      [{Quill vende a joia}]
      [{Quill vence}]
      [{Thanos vence}
      [{Thanos fica com a joia}]
      ]
      ]
      ]
        ]
      ]
        ]
    ]
  ]
\end{forest}
\end{document}
1
  • First, add fill=purple,text=white,edge=purple, into your tree declaration.
    – SebGlav
    Apr 4, 2021 at 17:44

1 Answer 1

1

I don't know what document class you used so here's an example of what you can do:

\usepackage{tikz}
\usepackage{forest}% for version 1
\tikzset{darkp/.style={fill=purple!50!black},
        lightp/.style={fill=purple!50}}
        
\begin{document}
\begin{forest}
  for tree={
    grow'=0,
    draw,
    align=c,
    font=\sffamily,
    rounded corners,
    fill=purple,
    text=white,
    edge=purple,
    parent anchor=east,
    child anchor=west,
    edge path={%
      \noexpand\path [\forestoption{edge}] (!u.parent anchor) -- ++(5pt,0) |- (.child anchor)\forestoption{edge label};
    }
  },
  highlight/.style={
    thick,
    font=\sffamily\bfseries
  }
  [{Peter Quill \\ rouba a joia}
        [{Kree captura Quill}
        [{Quill foge sem a joia}]
     [{Quill foge com a joia}
        [{Quill tenta vender a joia}
         [{Luta com Ronan}
         [{Vence}
         [{Joia é entregue a Tropa Nova}
         [{Thanos consegue a joia}]
         ]
         [{Quill fica com a joia}
         [{Thanos vence}
         [{Thanos fica com a joia},darkp]
         ]
         [{Quill vence}
         [{Thanos fica sem a joia},lightp]
         ]
         ]
         [{Quill entrega a joia para Youndu}
         [{Youndu vence}
         [{Thanos fica sem a joia},lightp]
         ]
         [{Thanos vence}]
         [{Thanos fica com a joia},darkp]
         ]
         ]
         ]
         [{Perde}
         [{Thanos fica sem a joia},lightp]
         ]
         ]
         [{Quill vende a joia}
         [{Thanos fica sem a joia},lightp]
         ]
         ]
    [{Quill escapa}
      [{Quill fica com a joia}
      [{Quill vende a joia}]
      [{Quill vence}]
      [{Thanos vence}
      [{Thanos fica com a joia},darkp]
      ]
      ]
      ]
        ]
      ]
        ]
    ]
  ]
\end{forest}
\begin{tikzpicture}[remember picture,overlay]
    \node[draw,rounded corners=5pt,fill=purple,text=white,font=\sffamily,inner sep=6pt] at (10,8) {Another Event};
\end{tikzpicture}
\end{document}
4
  • But can i paint some boxes in different colors?
    – evomoreira
    Apr 4, 2021 at 18:37
  • It's done like this: [{Thanos fica sem a joia},lightp], where lightp is a tikzset defined in teh preamble. Did you try my code?
    – SebGlav
    Apr 4, 2021 at 20:24
  • It works now. Actually, my overleaf wasn't recompiling properly, i have to refresh the page. Thank you Seb
    – evomoreira
    Apr 4, 2021 at 20:38
  • You're welcome. For your further questions, just think of giving the entire code, with the preamble, and especially the document class, which is sometimes important to find solutions.
    – SebGlav
    Apr 4, 2021 at 21:55

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.