What's the deal with Deno? We talk with a major contributor to find out. Listen now.

# Tag Info

93

Here's one option using the powerful forest package; since its built upon TikZ the customization possibilities are enormous. For example one can easily simulate the style produced by dirtree: \documentclass[border=5pt]{standalone} \usepackage{forest} \begin{document} \begin{forest} for tree={ font=\ttfamily, grow'=0, child anchor=west, ...

75

Having been having fun with straight-edge-and-compass constructions (thanks to What is the simplest way to draw this triangle exactly?), I thought I'd try my hand at a Christmas tree constructed using straight-edge and compass. (The animated version is about 5Mb. I'll have to stick it somewhere other than imgur and link to it.) \documentclass[ % handout, ...

67

Alan's answer works OK, but with the current version of Forest there is no need to define the edge path from scratch. Instead, we can use the edges library with the option forked edges. Moreover, we can eliminate growth parent anchor=east as it doesn't do anything (even in the old version of Forest), and we can use the parent and children anchors rather than ...

64

A bit late, but here's a simple Christmas tree for 2016: \documentclass[border=5]{standalone} \usepackage{tikz} \newbox\stereogrambox \pgfmathdeclarerandomlist{colors}{{red}{green!50!black}{green}{white}{blue}} \begin{document} \setbox\stereogrambox=\hbox{% \begin{tikzpicture}[x=1/2pt,y=1/2pt] \foreach \x in {0,...,95} \foreach \y in {0,...,119}{ \...

64

Previous solutions don't really use the fact that the tree can be completely generated procedurally (I think this is what the OP originally intended): And the picture will change every year! :) Tree for 2012: Tree for 2013: Tree for 2014: Tree for 2015: Tree for 2016: Tree for 2017: Tree for 2018: Tree for 2019: The solution added a new rule to the ...

58

I am going to put in a plea on behalf of forest. Although forest is extremely flexible and powerful, it can also be used very simply. Like qtree, it uses a simple, concise syntax which 'reads like a tree' but I found forest's syntax a bit easier to learn. (However, this may be because I learnt qtree first.) Like tikz-qtree, it gives you all the power of TikZ ...

53

43

We are still within the 12 days of Christmas and the wise men have not yet arrived bearing gifts, so I trust that I do not arrive too late. I wondered... If we have trees, why not a forest? There is, of course, no reason whatsoever to draw a Christmas tree using forest.... Nadolig Llawen! Note that the current code has been updated to work with Forest ...

40

This is not very difficult to do with forest. The following example should get you started. \documentclass{article} \usepackage{forest} \begin{document} \begin{forest}for tree={ grow=east parent anchor=east, child anchor=west, math content, edge path={\noexpand\path[\forestoption{edge},->, >={latex}] (!u.parent anchor) --...

36

As already mentioned, the only real solution is to define a new shape, with correct border anchors. So, here it is: rectangle with rounded corners. The radius of the corner is controllable by /pgf/rectangle corner radius. \documentclass{article} \usepackage{tikz} \usetikzlibrary{intersections} \begin{document} \makeatletter \pgfkeys{/pgf/.cd, ...

33

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}

26

The trees library provides a grow cyclic key/growth function. A few styles for the levels and a few child foreach path operators give you the following. Code \documentclass[tikz]{standalone} \usetikzlibrary{trees} \begin{document} \begin{tikzpicture}[ grow cyclic, level distance=1cm, level/.style={ level distance/.expanded=\ifnum#1>1 \...

26

Here's another option using forest to illustrate some other of its features: \documentclass{standalone} \usepackage{tabularx} \usepackage{forest} \usetikzlibrary{shapes.geometric} % comment out the following four lines if the Helvet Neue font are not available: \usepackage{fontspec} \newfontfamily\namefont[]{Helvetica Neue Condensed Bold} \...

22

The newly released genealogytree package would help you! This post previously mentioned version 0.10 alpha I had to install the current version manually, because the current Latex distribution is frozen until the new upgrade. A current example of what can be done with the package: http://mirrors.ctan.org/macros/latex/contrib/genealogytree/genealogytree-...

22

This answer uses a completely different approach since the code was unfortunately lost from the original version of the question. It may be less helpful since it is not based on that code, but I will leave it here since it may be of use to somebody at some point. Here's a basic Forest style, tableaux, which might be used for this kind of diagram. The ...

17

I defined a /forest/visible on option that passes its argument to /tikz/visible on to affect the actual node, and /forest/edge (this is the reason we need a visible on option in the /forest tree). I asume you also want all following children (and their edges) to be invisible that's why we actually use for tree (meaning the subtree). Other useful options ...

15

This is far from perfect but does the job, though, I would use other connections. Code \documentclass[tikz]{standalone} \usepackage{forest,calc} \forestset{ make tab/.style args={#1:#2:#3/#4:#5:#6/#7:#8:#9}{% content={% \tabcolsep=.6\tabcolsep \begin{tabular}{p{\widthof{x}}|p{\widthof{x}}|p{\widthof{x}}} #1 & #2 & #3\\\...

15

You could use forest which I've recently been learning to use for tree diagrams. This code owes pretty much everything to Gonzalo Medina's answer to my question about using forest in this way: \documentclass[tikz,12pt]{standalone} \usetikzlibrary{calc,positioning,backgrounds,arrows.meta} \usepackage{forest} \pagestyle{empty} \begin{document} \begin{forest}...

14

Update: Forest now provides this style more-or-less out-of-the-box. If you need a solution for older versions of Forest (for whatever reason), see my original answer below for the definition of a suitable style. Forest v.2 Here's a forest solution which uses the folder style provided by the edges library. This requires version 2 of Forest. \documentclass[...

14

I'm happy to report that the answer is yes, at least to some extent. I have created a style for forest which achieves code compatibility: the documents containing qtree trees can be used as they are, changing only \usepackage{qtree} to \usepackage{forest-qtree}. (Note an exception to this statement: any commas in the node labels must be enclosed in braces; ...

14

You need to do \begin{forest} for tree={edge path=<your path>}} (without []!). I adjusted the distance a little bit, better would be to use for example half the level distance and not a fixed distance. One can also use my paths.ortho library (needs both tikzlibarypaths.ortho.code.tex and tikzlibarypaths.ortho.tex) and be available to use |-| instead ...

14


14

Using forest: \documentclass{article} \usepackage{forest} \newcommand\mytable[5]{% #1\\ \begin{tabular}[t]{*{3}{|c}|} \hline & T1 & T2 \\ \hline T1 & #2 & #3 \\ \hline T2 & #4 & #5 \\ \hline \end{tabular}% } \begin{document} \begin{forest} for tree={parent anchor=south, child anchor=north,l=2cm,edge={->}}, for descendants={text ...

14

The most recent release of PGF has a number of graph drawing algorithms (requiring lualatex) including a version of the Reingold–Tilford method and can easily handle large numbers of nodes. In the simplest case a tree can be specified like this: \documentclass[tikz,border=5]{standalone} \usetikzlibrary{graphs,graphdrawing,arrows.meta} \usegdlibrary{trees} \...

13


13

A later version of this package is now on CTAN - updated answer to reflect current usage etc. NEW ANSWER - UPDATED I finally got fed up with not having a better solution to offer people. Logic is not well served, particularly for teaching lower level classes. My solution is a new package. It certainly contains bugs and it is not altogether automatic. ...

13

Consider that this is not the right approach at all, but I am not an expert and this is the only way I know. \documentclass[border=0.5cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} % \draw [help lines] (0,0) grid (13,13); \draw [thick] (0,0) -- (0,10); \draw [thick,-latex] (0,5) -- + (0.5,0) node [right] {\$A<T<A_{f}...

12

Rewrite of one of Gonzalo Medina's trees above for Forest v2 which makes it much easier to draw this kind of tree. Updated versions of two of the other styles: https://tex.stackexchange.com/a/361248/ and https://tex.stackexchange.com/a/328987/. \documentclass[tikz,border=10pt,multi,dvipsnames,svgnames,x11names]{standalone} \usepackage[edges]{forest} \...

12

One way is to use the missing option. This method is probably the most natural considering what you want to achieve : "as if there was a sibling". \begin{tikzpicture} \node {root} child { node {left} } child { node {right} child[missing] {node {}} child { node {rightmost} } } ; \end{...

Only top voted, non community-wiki answers of a minimum length are eligible