4

I'm embarrassed about the choice of the package used to produce rooted trees like this rooted trees

I have the option of the forest package Example1, The xymatrix package example2, or pst-tree package Example3 or Tikztrees, Trees.

I'm going to stop and shed more light on the subject so as not to clutter up and obscure the issue.

Question: "What is the most appropriate choice I can make among these packages (or others if there are any)? "

Thank you very much for your precious advices.

3

This is just to honorably mention one option that does not seem to have been mentioned above: trees from the graphdrawing library. The advantage is a short code, the disadvantage is that you have to use lualatex.1 Here is an example.2

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{graphs,graphdrawing} 
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[rn/.style={label={[anchor=center,circle,draw,minimum
    size=5pt,inner sep=0pt]center:}},
    graphs/every graph/.style={anchor at={(0,0.5em-0.5*\pgfmatrixcurrentrow*1em)},
    empty nodes,tree layout,level distance=1em, sibling
    distance=1em,grow=90,nodes={circle,fill,minimum size=3pt,inner sep=0pt,outer sep=0pt}}]
\matrix[row sep=1em,column sep=1em]{
\node{1}; & \graph { 1[rn]}; \\
\node{2}; & \graph { 1[rn]--2}; \\
\node{3}; & \graph[anchor at={(0,-1em)}] { 1[rn]--2--3}; &
\graph { 1[rn]--{2,3}}; \\
\node{4}; & \graph { 1[rn]--2--3--4}; &
\graph { 1[rn]--2--{3,4}};
& \graph { 1[rn]--{2,3--4}};
& \graph { 1[rn]--{2,3,4}};\\
};
\end{tikzpicture}
\end{document}

enter image description here

1To avoid lengthy discussions: I am not suggesting that there is something wrong with lualatex. However, you cannot upload the above to the arXiv, which is IMHO a disadvantage.

2I am not a big fan of posts without an explicit example that allows one to back up the statements.

| improve this answer | |
2

To some extent this is an opinion based question, since it's really up to you to decide on the usefulness of particular packages. Two of the questions you've linked to also show quite different sorts of trees than the ones you show in your image. I'll try to lay out what criteria you might use to decide on a package, however.

  1. Are the representations you are drawing (rooted) trees in the formal sense (i.e., graphs in which any two vertices are connected by exactly one path and with a designated root)? If so, then specific tree drawing packages like tikz-qtree, forest and pst-tree, pst-jtree, xytree can be appropriate. If the representations you are drawing are not trees, then these packages may not be the best solution, and the TikZ graph drawing methods may be helpful here.

  2. If the representations are trees in the formal sense, then the following criteria are relevant. Here I'll consider 5 packages: tikz-qtree, forest, pst-tree, pst-jtree, xytree. I don't consider the base TikZ tree methods, as I find their input syntax very unwieldy, but TikZ does have more general graph drawing capabilities that are useful.

    • ease of input syntax (tikz-qtree and forest clearly win here)
    • ability to be used with any engine (TikZ methods clearly win over pstricks)
    • need to annotate trees with edge labels, or other connections between nodes (forest wins in the general case, but the specialized istgame package for game trees is also very good, if those are the kinds of trees you are drawing.)

All of the pstricks based methods share similar joint problems: they are dependent on using latex+dvips (or possibly xelatex), and they generally have an input syntax that is not particularly friendly. The TikZ methods are engine independent (although some advanced libraries use lualatex).

| improve this answer | |
  • Thank you very much for your responses! And thank you for your patience. Sincerely. – Furdzik Jun 6 at 21:19

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.