Changes between Version 3 and Version 4 of TreeMagic


Ignore:
Timestamp:
Oct 30, 2011, 4:44:46 PM (6 years ago)
Author:
joerg
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TreeMagic

    v3 v4  
    66For example the tree
    77
    8   [[Image(http://common.jle.cc/features/tree.png)]]
     8 [[Image(http://common.jle.cc/features/tree.png)]]
    99
    1010is generated by the code:
     
    2626}}}
    2727
    28  * Trees now can simply be written as terms, for example 'f(g(a,b),h(c))'. Then we have
     28 * Trees now can simply be written as terms, for example '''f(g(a,b),h(c))''' for the tree
     29
     30   [[Image(http://common.jle.cc/features/tree_simple.png)]]
     31
     32 Then we have
    2933{{{
    3034%!begin{tree}{magic:023916255455191981}
     
    3337}}}
    3438
    35  * We again press ('''alt+enter''') to invoke Tree Magic,
    36    then the Tikz tree is automatically generated and inserted in the document as follows:
     39 * We again press ('''alt+enter''') to invoke Tree Magic.
     40   Then the corresponding Tikz code is generated and inserted in the document:
    3741{{{
    3842%!begin{tree}{magic:023916255455191981}
     
    5559}}}
    5660
    57    [[Image(http://common.jle.cc/features/tree_simple.png)]]
     61 * Here the whole Latex source code of this example:
     62{{{
     63\documentclass{article}
    5864
    59  * [wiki:Development]
     65\usepackage{tikz}
     66\usetikzlibrary{arrows,backgrounds,calc,trees}
     67
     68\begin{document}
     69\thispagestyle{empty}
     70
     71\begin{tikzpicture}[thick,level distance=12mm,
     72  paint/.style={very thick,draw=#1!50!black,fill=#1,opacity=.3}]
     73%!begin{tree}{magic:023916255455191981}
     74%f(g(a,b),h(c))
     75\node (f) {f}
     76    child { node (g) {g}
     77      child { node (a) {a}
     78    }
     79      child { node (b) {b}
     80    }
     81  }
     82    child { node (h) {h}
     83      child { node (c) {c}
     84    }
     85  };
     86\begin{pgfonlayer}{background}
     87\end{pgfonlayer}
     88
     89%!end{tree}{magic:023916255455191981}
     90\end{tikzpicture}
     91
     92\end{document}
     93}}}
     94
     95== Highlighting parts of the tree ==
     96
     97 * We continue the previous example. To highlight a the nodes {g,a,b}, simply write '''highlight[paint=red](g, a, b)'''
     98{{{
     99%!begin{tree}{magic:023916255455191981}
     100%f(g(a,b),h(c))
     101%highlight[paint=red](g,a,b)
     102... generated code ...
     103%!end{tree}{magic:023916255455191981}
     104}}}
     105  Then press ('''alt+enter''') to invoke Tree Magic, and you obtain the tree:
     106
     107  [[Image(http://common.jle.cc/features/tree.png)]]
     108
     109 * Of course we can highlight multiple parts of the tree:
     110{{{
     111%!begin{tree}{magic:023916255455191981}
     112%f(g(a,b),h(c))
     113%highlight[paint=red](g,a,b)
     114%highlight[paint=blue](f,g,h,c,h)
     115... generated code ...
     116%!end{tree}{magic:023916255455191981}
     117}}}
     118  Then press ('''alt+enter''') to invoke Tree Magic, and you obtain the tree:
     119
     120  [[Image(http://common.jle.cc/features/tree_highlight.png)]]
     121
     122== Complex nodes (math mode) ==
     123
     124  * To create complex nodes (e.g. with mathematical formulas),
     125    we can surround the node with braces ('{' and '}') or quotes ('"').
     126
     127  * For example,
     128{{{
     129%{$f^2(x)$}({$g_h$}(a,b),{h+3}(c))
     130%highlight[paint=red](g_h,a,b)
     131%highlight[paint=blue](f^2x,g_h,h+3,c,h+3)
     132}}}
     133  will result in the tree:
     134
     135  [[Image(http://common.jle.cc/features/tree_math.png)]]
     136
     137  * Note the naming of the nodes in the highlight section!
     138    You find more on the naming of nodes in the following section.
     139
     140
     141== Node naming ==
     142
     143  * By default, the names of the nodes are derived from the
     144    content of the nodes by removing all symbols '()[]{}\$'.
     145    Thus the node '''$f!^2(x)$''' will be named '''f!^2x'''.
     146
     147  * You may use custom names by '''node:name'''.
     148    For example '''{$f!^2(x)$}:root''' will assign the name 'root' to the node.
     149    Then the code:
     150{{{
     151%{$f^2(x)$}:root({$g_h$}(a,b),{h+3}(c))
     152%highlight[paint=red](g_h,a,b)
     153%highlight[paint=blue](root,g_h,h+3,c,h+3)
     154}}}
     155  results in the same picture as above,
     156  but now we use 'root' to refer to '$f!^2(x)$' in the highlight section.
     157
     158  * You can use these names to refer to the nodes from Tikz.
     159    For example to add an arrow from 'c' to the root, add
     160{{{
     161\draw [->,very thick] (c) to[bend right=80] (root);
     162}}}
     163  after the Tree Magic section. This results in:
     164
     165   [[Image(http://common.jle.cc/features/tree_naming.png)]]
     166
     167== Tikz options ==
     168
     169  * You may pass Tikz drawing options to a node via '[options]' after the node name.
     170    For example:
     171{{{
     172%f[rectangle,fill=green!50,draw=green!50!black](g(a,b),h(c))
     173%highlight[paint=red](g,a,b)
     174}}}
     175  will result in:
     176
     177   [[Image(http://common.jle.cc/features/tree_options.png)]]
     178
     179  * We can provide more Tikz options as follows:
     180{{{
     181%f([options1] [options2] g [options3](a,b),h(c))
     182}}}
     183  which results in the following options being passed to child 'g':
     184{{{
     185... [options1] child [options2] { node [options3] (g) {g} ...
     186}}}