# How can I make a tree (forest) with simple commands like Geophar?

I use Geophar http://sourceforge.net/projects/geophar/ With this Program, I can easy to make a tree. With the code

||Tirage 1|Tirage 2|Tirage 3
omega
>A:0,7
>>B:0,2
>>C:0,8
>&A:0,3
>>E:0,1
>>>F
>>>G
>>>H
>>&E:0,9


I got the tree.

How can I make simple code in tree package or forest package like above code?

• What do you mean? Obviously, to use those packages, you have to use those packages' syntax. You can't expect them to work with syntax from a completely different software programme.
– cfr
Nov 6 '15 at 3:27
• @cfr Can I make a code in order to write, easy to understand and easy to practice? I see that, Geophar is easy to use. Nov 6 '15 at 3:30
• I think the bracket notation is pretty easy. I think the Geophar code you posted less easy. It is just a question of what you are used to. You can always use Geophar and \includegraphics{} but writing something to parse your tree in order to turn it into forest code or whatever, which then uses special tricks to parse the tree.... Well, of course you can. You can write whatever tree-drawing package you like. For me, I think life too short when other people have already done the job;).
– cfr
Nov 6 '15 at 3:49
• Don't reinvent the wheel.... Not unless you are really, really, really sure that your new triangular design will be easier to use, more aesthetically pleasing and more efficient than the currently available circular forms favoured by existing manufacturers.
– cfr
Nov 6 '15 at 3:51
• Or you could use TikZ's graph-drawing syntax. That's not specifically for trees, of course. Or specify it as a matrix of nodes, say, and then draw the edges in later?
– cfr
Nov 6 '15 at 3:59

forest uses bracket notation for specifying trees which is, I believe, pretty standard (or a variation on standard syntax). I find this fairly intuitive - much more so than qtree's version, for example.

For an introduction to forest's syntax and some basic uses of the package see the second part of my answer which tries to provide a kind of basic getting-started.

In the following example, note that the specification of the tree is extremely concise. Indentation makes it easier to 'read' the tree structure from the code.

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
/tikz/every node/.append style={font=\sffamily},
my edge/.style={%
if n=1{
edge label={node [midway, above, font=\scriptsize, sloped, anchor=south] {#1}},
}{
edge label={node [midway, below, font=\scriptsize, sloped, anchor=north] {#1}},
}
},
toss/.style={
before drawing tree={
tikz/.wrap pgfmath arg={\node at ([yshift=10pt].center |- h.north) {Tirage ##1};}{level()},
}
},
tosses/.style={
for ancestors'={if level=0{}{toss}},
before packing={
!1.tikz={\node at ([yshift=10pt].center |- h.north) {Outcomes};}
}
},
for tree={
grow'=0,
parent anchor=east,
child anchor=west,
anchor=west,
tier/.wrap pgfmath arg={tier #1}{level()},
l sep+=20pt,
font=\sffamily,
math content,
},
[\Omega
[A, my edge=0.7
[B, name=h, my edge=0.8]
[C, my edge=0.2]
]
[\overline{A}, my edge=0.3
[E, my edge=0.1
[F]
[G]
[H, tosses]
]
[\overline{E}, my edge=0.9
]
]
]
\end{forest}
\end{document}