wiki:TreeMagic

Version 3 (modified by joerg, 6 years ago) (diff)

--

About

Tree Magic allows to draw beautiful (Tikz) trees within a few seconds by providing a much simpler syntax than the original Tikz library.

For example the tree

http://common.jle.cc/features/tree.png

is generated by the code:

f(g(a,b),h(c))
highlight[paint=red](g, a, b)

Getting started

  • To start Tree Magic, simply write
    %!begin{tree}
    
    and press (alt+enter). This will automatically generate the following code:
    %!begin{tree}{magic:023916255455191981}
    % 
    %!end{tree}{magic:023916255455191981}
    
  • Trees now can simply be written as terms, for example 'f(g(a,b),h(c))'. Then we have
    %!begin{tree}{magic:023916255455191981}
    %f(g(a,b),h(c))
    %!end{tree}{magic:023916255455191981}
    
  • We again press (alt+enter) to invoke Tree Magic, then the Tikz tree is automatically generated and inserted in the document as follows:
    %!begin{tree}{magic:023916255455191981}
    %f(g(a,b),h(c))
    \node (f) {f}
        child { node (g) {g}
          child { node (a) {a}
        }
          child { node (b) {b}
        }
      }
        child { node (h) {h}
          child { node (c) {c}
        }
      };
    \begin{pgfonlayer}{background}
    \end{pgfonlayer}
    
    %!end{tree}{magic:023916255455191981}
    

http://common.jle.cc/features/tree_simple.png