# Tag Info

5

For simple, non "graphical" tree you can use the dirtree package: \documentclass{article} \usepackage{dirtree} \begin{document} \dirtree{% .1 debug. .2 filename. .2 modules. .3 module. .3 module. .3 module. .2 level. } \end{document}

0

May I recommend forest in addition to standalone? It allows you to specify the tree more compactly, without reducing the font size quite so much. (I used \tiny only for the edge labels and \small for the nodes.) Moreover, you can automate the placement of labels and make them more readable, and reduce the amount of repetition in the form of explicit mark up. ...

1

With forest you can generally do this quite nicely using the nice empty nodes style (page 52, example 81). However, sometimes it doesn't quite work that simply. Your tree is one such example. Nonetheless, it is possible to get the tree very nearly perfect to the point that I challenge anybody to know that the tree does not use the unadulterated form of nice ...

0

Trees do well in forests... \documentclass[tikz,a4paper,border=5pt]{standalone} \usepackage{forest} \begin{document} \begin{forest} for tree={ math content, circle, draw } [C3 [, phantom] [i [, phantom] [j ] ] ] \end{forest} \end{document}

4

Even with forest which can do a lot of things automatically, a certain amount of manual tweaking is needed. There is just no way for it to know what the content of the node means. However, forest does allow you to integrate the loops into the tree which may be attractive in some cases. For example: \documentclass[tikz,border=5pt]{standalone} ...

2

This solution is not as pretty as the hand-drawn version. However, it is somewhat automatic. That said, it will certainly produce unwanted results if a tree differs too significantly from the one I tested it on. The solution uses forest (of course). I wanted to get intersections using the intersections library in order to draw neater paths when the number ...

1

Here's a simple forest solution: \documentclass[tikz, border=5pt]{standalone} \usepackage{forest} \begin{document} \begin{forest} for tree={ circle, draw } [A [B [E] [F [K] [L] [M] ] [G] ] [C [H] ] [D [I] [J [N] [O] ] ] ] ...

2

forest offers a label option which can be used for this and makes quite a neat tree from very compact code. I'm not sure just how the tree should look so this may not be quite right, but it can be modified fairly easily. \documentclass[tikz, border=5pt]{standalone} \usepackage{forest} \begin{document} \begin{forest} /tikz/label position=right, ...

0

forest can automatically handle the insertion and placement of ellipses as required. For example: \documentclass[tikz, border=5pt]{standalone} \usepackage{forest} \begin{document} \forestset{ gappy/.style={ before typesetting nodes={ insert after={ [\dots, no edge] } } } } \tikzset{ document element/.style={ rounded ...

2

Here's a (very late) forest solution just because I wanted to draw the curvy paths. \documentclass[tikz,border=5pt]{standalone} \usepackage{forest} \begin{document} \begin{forest} my label/.style={label={[label distance=-5pt, font=\sffamily]-45:#1}}, for tree={ circle, draw, font=\sffamily, parent anchor=south, edge path={ ...

1

This answer uses version 0.07 of an experimental package, prooftrees. This is based on forest and all of the magic is being done by that package. The key single branches is provided by prooftrees and is needed to get the spacing right in this case. \linecountformat is also provided by the package (and was added for the purpose of answering this question - ...

2

With forest, you can easily specify complex sub-trees, format them in different ways and mix explicit and automatic node creation within your tree. And you can do all this very concisely and without needing to worry about expansion issues. (At least, usually not.) For example: \documentclass[tikz,border=5pt,multi]{standalone} \usepackage{forest} ...

0

Maybe this helps a little: \documentclass[12pt]{article} \usepackage{newicktree} \begin{document} \begin{figure}[h!] \centering \begin{newicktree} \setunitlength{4cm} \nobranchlengths \nodelabelformat{} \contemporarytips[30] \drawtree{ (((A,B)X,C)Y,D)Z;} \end{newicktree} \caption{Example of phylogenetic tree.} \label{fig:phyltree} ...

5

edge label will override any previous value for any particular node. So the first label disappears. But we can use the same method as I used for the sub optimal style i.e. declare another option, just like edge label and then add it to the redefinition of edge path. \documentclass{beamer} \usepackage{etex,forest} \usetikzlibrary{shapes,snakes} \tikzset{ ...

3

This is a bit of a "hack", but you can simply set an extra label without the above or below keys. Then using \\ when you want to switch to the "other line", they will show one above, one below. So basically, you'll have: my above my below my label (both) As far as you've showed, this will work. If there is some situation where this behaviour breaks, ...

0

Thanks, @cfr and @AlanMunn. I have adapted @cfr's answer to the original decision tree. \documentclass{beamer} \usepackage{tikz} \usetikzlibrary{trees,shapes,snakes} \usepackage{forest} \tikzset{ decision/.style={rectangle, minimum height=10pt, minimum width=10pt, draw=black, fill=black!30!white, thick, inner sep=0pt}, chance/.style={circle, ...

2

Here's an example based on code I posted in response to one of your earlier questions. sub optimal crosses through the relevant branch of the tree. \documentclass[tikz,border=5pt]{standalone} \usepackage{forest} \usetikzlibrary{shapes} \tikzset{ decision/.style={rectangle, minimum height=10pt, minimum width=10pt, draw=black, fill=black!30!white, thick, ...

2

Here's a simple example of how to cross out a branch of a tree. \documentclass{article} \usepackage{forest} \usepackage{mathtools} \newcommand{\verteq}{\rotatebox{90}{$=$}} \begin{document} \begin{forest} crossed/.style={edge label={node[midway, sloped]{$\verteq$}}} [A [B [C,crossed ] [D ] ] [E,crossed ] [F,crossed ]] \end{forest} \end{document}

5

Output Answers See the comments in the code for further explanation, but here's a summary of how I addressed your questions: I used \begin{scope} and \end{scope} around the code for the semantic trees so that they can be scaled and shifted independently. The surface scope tree has [xshift=9cm,scale=.8], so it's shifted right by 9 cm and shrunk by 20%. ...

7

Here's a method which keeps the labels at the end of the lines but changes their anchors, right aligns the numbers labelling the triangles and fiddles a little with the straight line approach: \documentclass{beamer} \usepackage{forest} \usetikzlibrary{shapes} \tikzset{ decision/.style={rectangle, minimum height=10pt, minimum width=10pt, draw=black, ...

5

There's no optimum solution for your edge labels, I don't think. The easiest solution is to just move them a little to the left with the pos= argument. Here I've set it to .4 to accommodate the length of the 'No Accident' label. To make the triangles you can add another style using the isosceles triangle shape: \documentclass{beamer} ...

3

The arrow in your example is a cubic Bézier curve, so it has two control points that "guide" the direction of the curve. The position of the first control point is specified by +(south west:5) and the position of the second control point is specified by +(south:5). The following code, adapted from this answer to What type of curve is used by Tikz when I ...

3

Simply use \nodes with names for those elements and then use the names to connect them: \documentclass[12pt,a4paper]{article} \usepackage{tikz-qtree} \usepackage{tikz-qtree-compat} \usepackage{ulem} \def\hcancel#1{}% provissional definition; delete this line in your actual code \begin{document} \begin{tikzpicture} \Tree ...

2

I'm not sure I understand where your confusion lies, since the (tikz-)qtree syntax for this is pretty standard in-line bracket structure (plus periods and spaces in the right places). You just use [. to introduce a node, which can be followed by further instances of [. to create recursion. Then use <space>] to close each node. Here's a tree with some ...

2

Just some pictures... \documentclass[a4paper]{article} \usepackage{tikz-qtree,tikz-qtree-compat,forest} \begin{document} The base of the following tree is aligned with the baseline \begin{tikzpicture}[baseline=(current bounding box.south)] \Tree [.X X Y ] \end{tikzpicture}, whereas the top of the next is aligned with the baseline ...

1

A compact forest solution which uses baseline to set an empty node to the baseline of the tree. \documentclass[12pt,a4paper]{article} \usepackage{forest} \begin{document} X + Y $\Rightarrow$ \begin{forest} for tree={align=center, parent anchor=south, child anchor=north, if n children=0{tier=t}{}} [{X\\$[\dots]$} [{X\\$\langle\alpha\rangle$}] [, ...

2

The vertical placement of the figure can be done in many different ways. There is option baseline. Setting it to the center of the image (current bounding box.center) puts the middle on the current baseline of the surrounding text. The third example will show a way to center the image around the current math axis. The second image puts the leafs on the same ...

1

\documentclass[12pt,a4paper]{article} \usepackage{tikz-qtree} \usepackage{tikz-qtree-compat} \usepackage{stackengine} \begin{document} \raisebox{3\baselineskip}{X + Y $\Rightarrow$} \tikzset{level 1/.style={level distance=60pt,sibling distance=30pt}} \begin{tikzpicture} \Tree [.\stackunder{X}{$\langle$...$\rangle$} \stackunder{X}{$\langle\alpha\rangle$} ...

1

Here's a forest solution which defines a new style dir tree which can be used to typeset trees in this format. \documentclass[tikz, border=5pt, multi]{standalone} \usepackage{forest} \usetikzlibrary{arrows.meta} \forestset{ dir tree/.style={ for tree={ parent anchor=south west, child anchor=west, anchor=mid west, inner ...

2

Just a simple way to draw a directory-style tree using forest: \documentclass[tikz, border=5pt, multi]{standalone} \usepackage{forest} \usetikzlibrary{arrows.meta} \begin{document} \begin{forest} for tree={ parent anchor=south west, child anchor=south west, anchor=mid west, inner sep=1pt, l sep+=-1.5em, grow'=0, align=left, ...

4

A forest solution though there are better versions around if you search, I think. This is not exactly like the image you linked to because that one seems rather ugly to me. Obviously, you can adjust this if you prefer greater ugliness. \documentclass[tikz,border=5pt]{standalone} \usepackage{forest,nicefrac} \usetikzlibrary{positioning} \begin{document} ...

Top 50 recent answers are included