# Which is the best package for drawing rooted trees and how do you use it? [closed]

Which package is easy to use: forest, qtree or some other package, for drawing rooted trees like in the picture below? (I need to be able to draw the trees, draw trees with cuts, use the trees in equations a lot, and maybe occasionally label the edges and vertices.)

How do you use the package to draw the rooted trees in the picture? (What are the semantics?)

(Also, is there a difference between qtree and tikz-qtree or are they the same package?)

## closed as primarily opinion-based by Zarko, Stefan Pinnow, CarLaTeX, Werner, JanFeb 19 '17 at 8:23

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

• I can't help you on semantics of the packages but you can look for their documentations for example on ctan.org. – Skillmon Feb 18 '17 at 18:17

*I think I ought not answer do-it-for-mes (or questions which are edited in ways which invalidate existing answers). But I'm procrastinating and like trees, so will do what I ought not. *

However, I provide such answers on a strictly 'as is' basis. I will be less sympathetic to queries, requests for explanation and desires for fine-tuning. I answer such questions for me. If such answers happen to be useful to somebody, great. If not, tough.

# EDIT (new question)

\documentclass[border=10pt]{standalone}
\usepackage{forest}
\usetikzlibrary{shapes.geometric,decorations.markings}
\forestset{
my tree/.style={
before typesetting nodes={
for tree={
if={>O+tt=!O_=&{content}{}{n}{1}}{
label/.process={Ow}{content}{left:##1},
}{
label/.process={Ow}{content}{right:##1},
},
content=,
},
},
where level=0{
draw,
baseline,
diamond,
}{
draw,
fill,
circle,
},
for tree={inner sep=1.5pt, s sep'+=10pt},
},
default preamble={my tree},
cut/.style={
tikz+={
\path [decorate, decoration={markings, mark=at position .5 with {\draw [] +(90:2.5pt) -- +(-90:2.5pt);}}] ()  -- (!u);
}
}
}
\begin{document}
\begin{forest}
[
[[[][]]]
[[]]
]
\end{forest}
\begin{forest}
[
[$c_1$, edge label={node [midway, left] {$a_2$}}]
[$f_2$, edge label={node [midway, right] {$b_1$}}
[$v_1$
[, phantom]
[$v_2$]
]
]
]
\end{forest}
\begin{forest}
[
[, cut
[]
]
[, cut]
]
\end{forest}
\end{document}


# ORIGINAL (first question)

No answer to your question can possibly be satisfactory as the question asks for more than can possibly be said here and is, in any case, not well-defined.

Instead, I present CTAN's Tree topic in tree format as an illustration of the fact that the only possible answer is

It depends.

On what?

On a lot of things ....

[One question this illustration does answer is whether qtree and tikz-qtree are the same package.]

There are, in fact, more packages for drawing trees, but not all are included in CTAN's topic or, even, on CTAN. Some of these are obsolete, many deprecated. Some may not work at all.

The easiest to learn?

What do you know?

The easiest to use?

For what purpose? How often? What's your work-flow? What do you like?

The best-looking?

In whose eyes? What kind of trees? What audience? What do you like?

For rooted trees?

All trees have roots, by definition. A rootless tree - or, which comes to the same thing, a multi-rooted tree - is not a tree, but a graph.

You?

Me, I will tell you to learn prooftrees. But it draws a very particular kind of tree.

For other trees?

Me, I will tell you to learn Forest. But it is not the easiest to learn or use and it does not always give the best results. Some kinds of trees it cannot draw at all.

\documentclass[border=10pt,multi,tikz]{standalone}
\usepackage[edges]{forest}
\usepackage{cfr-lm}
\begin{document}
\begin{forest}
forked edges,
before typesetting nodes={
for tree={
split option={content}{:}{content,desc},
},
},
desc/.style={
font=\ttfamily,
l sep'=0pt,
delay={append={[{#1}, font=\footnotesize\sffamily, rotate=-90, child anchor=west, no edge]}}
},
for tree={
font=\sffamily\small,
s sep'-=5pt,
}
[CTAN
[Topic tree
[{\texttt{(e)epic}, PIC\TeX{} etc.}
[baum:{Trees, using  PiC\TeX}]
[ecltree:{Trees using epic  and eepic macros}]
]
[MP
[drv:{Derivation trees  with METAPOST}]
]
[PS
[pst-Jtree:{Typeset complex  trees for linguists}]
[pst-qtree:{Simple syntax  for trees}]
[pstrees:{Construct linguistics  trees using a  preprocessor}]
[pst-tree:{Trees, using PSTricks}]
[pst-tvz:{Draw trees with  more than one  root node, using  PSTricks}]
]
[Ti\emph{k}Z
[binarytree:{Drawing binary  trees using  Ti\emph{k}Z}]
[forest:{Drawing  (linguistic) trees}]
[prooftrees:{Forest-based  proof trees  (symbolic logic)}]
[tikz-dependency:{A library for  drawing dependency  graphs}]
[tikz-qtree:{Use existing  qtree syntax for  trees in Ti\emph{k}Z}]
[ texttt{trees}]
]
[XY
[xyling:{Draw syntactic  trees, etc., for  linguistics literature,  using xy-pic}]
[xytree:{Tree macros using XY-Pic}]
]
[Other
[dirtree:{Display trees  in the style of  windows explorer}]
[emtrees:{Draw labelled  trees, using em\TeX{}  specials}]
[qtree:{Draw tree  structures}]
[treedef:{Macros to typeset  trees in Plain \TeX}]
]
[??
[chomsky:{Macros to typeset  parsing trees}]
[dyntree:{Construct Dynkin  tree diagrams}]
[eppstein-trees:{Macros for  producing trees}]
[gl-tree:{Linguistic trees  with a preprocessor}]
[lingtrees:{Linguistics trees  preprocessor and macros}]
[linguex:{Format linguists' examples}]
[prftree:{Macros for building proof trees}]
[proofs:{Macros for building proof trees}]
[qobitree:{\LaTeX{} macros for typesetting trees}]
[RRGtrees:{Linguistic tree diagrams  for Role and Reference  Grammar (RRG)  with \LaTeX}]
[syntrace:{Labels for tracing in a syntax tree}]
[synttree:{Typeset syntactic trees}]
[tree-dvips:{Trees and other linguists' macros}]
[treesvr:{Tree macros}]
[treetex-ltx209:{Draw horizontally- or  vertically-oriented trees}]
[treetex-plain:{Draw trees}]
[williams:{Miscellaneous macros by Peter Williams}]
[wotree:{Draw Warnier/Orr diagrams}]
]
]
]
\end{forest}

\end{document}

• thank you for your response... i didnt realise that 'rooted trees' were more general structures. please see my edited question if you are able to respond. thanks – vkan Feb 22 '17 at 12:36
• @vkan I already answered your edited question: I'd use Forest. It is harder to learn, but more powerful. If you don't want to do that, try tikz-qtree. It is not as powerful or as flexible. I find its syntax more difficult than Forest's. (It uses qtree syntax. However, linguists seem to find either syntax equally intuitive. (But whether it is me vs. them or non-linguists vs. linguists or something else, I'm not sure.) – cfr Feb 22 '17 at 23:45
• @vkan My answer doesn't really make sense now, but I guess it might be useful to somebody sometime. – cfr Feb 22 '17 at 23:47
• Hi cfr, thanks for your help. I tried out your code but for some reason when i try it the nodes are coming out blank. Do you know why? Is it because i don't have some package downloaded like some tikz package? I have mactex-2015 installed i believe. Also i was trying to use newcommand with the forest environment in the preamble, so that i can reuse certain trees in my document but latex doesn't seem to be letting me do this. – vkan Mar 21 '17 at 22:45
• @vkan I have no idea why. I am using TeX Live 2016, so updating MacTeX might help. However, I'd expect you to get errors in that case. Read the output on the console or in the log for warnings etc. Without code and information about what not letting you do it means, I can't say anything about the \newcommand issue. Post a new question with a minimal example which reproduces the problem. But note that Forest has to read the entire contents of the environment in one gulp and so relies on environ. – cfr Mar 21 '17 at 23:11