summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-02-23 00:49:54 +0000
committerKarl Berry <karl@freefriends.org>2008-02-23 00:49:54 +0000
commit4fc1af1461e934c39f8f5e10d5d8788681d82223 (patch)
tree7716e8a3e8787a3d11c5ce728d21b808f786ce7d /Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex
parent6f5a4edf390b6e05291d7a4b816782b14122a205 (diff)
tikz/pgf 2.0 first attempt (22feb08)
git-svn-id: svn://tug.org/texlive/trunk@6741 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex')
-rw-r--r--Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex226
1 files changed, 139 insertions, 87 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex
index 53528ccfc04..f3f2a514f33 100644
--- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex
+++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-trees.tex
@@ -99,10 +99,8 @@ node {root} child[left] {node[left] {1}} child[right] {node[right] {2}}
You can nest things as in the following example:
\begin{codeexample}[]
-\begin{tikzpicture}[level distance=4mm]
- \tikzstyle{level 1}=[sibling distance=8mm]
- \tikzstyle{level 2}=[sibling distance=4mm]
- \tikzstyle{level 3}=[sibling distance=2mm]
+\begin{tikzpicture}
+ [level distance=4mm,level/.style={sibling distance=8mm/#1}]
\coordinate
child foreach \x in {0,1}
{child foreach \y in {0,1}
@@ -231,8 +229,8 @@ whole child,'' including all of its grandchildren. Here is an
example:
\begin{codeexample}[]
-\begin{tikzpicture}[thick]
- \tikzstyle{level 2}=[sibling distance=10mm]
+\begin{tikzpicture}
+ [thick,level 2/.style={sibling distance=10mm}]
\coordinate
child[red] {child child}
child[green] {child child[blue]};
@@ -300,31 +298,48 @@ Here is the set of rules:
\end{codeexample}
There are additional styles that influence how children are rendered:
-\begin{itemize}
- \itemstyle{every child}
+\begin{stylekey}{/tikz/every child (initially \normalfont empty)}
This style is used at the beginning of each child, as if you had
- given the options to the |child| operation.
- \itemstyle{every child node}
+ given the style's contents as options to the |child| operation.
+\end{stylekey}
+
+\begin{stylekey}{/tikz/every child node (initially \normalfont empty)}
This style is used at the beginning of each child node in addition
to the |every node| style.
- \itemstyle{level \meta{number}}
- This style is used at the beginning of each set of children, where
+\end{stylekey}
+
+\begin{stylekey}{/tikz/level=\meta{number} (initially \normalfont empty)}
+ This style is executed at the beginning of each set of children, where
\meta{number} is the current level in the current tree. For example,
- when you say |\node {x} child child;|, then the style |level 1| is
- used before the first |child|. If this first |child| has children
- itself, then |level 2| would be used for them.
+ when you say |\node {x} child child;|, then |level=1| is
+ used before the first |child|. The style or code of this key will be
+ passed \meta{number} as its first parameter. If this first |child|
+ has children itself, then |level=2| would be used for them.
\begin{codeexample}[]
-\begin{tikzpicture}
- \tikzstyle{level 1}=[sibling distance=20mm]
- \tikzstyle{level 2}=[sibling distance=5mm]
+\begin{tikzpicture}[level/.style={sibling distance=20mm/#1}]
\node {root}
child { child child }
child { child child child };
\end{tikzpicture}
\end{codeexample}
-\end{itemize}
+\end{stylekey}
+\begin{stylekey}{/tikz/level \meta{number} (initially \normalfont empty)}
+ This style is used in addition to the |level| style. So, when you
+ say |\node {x} child child;|, then the following key list is
+ executed: |level=1,level 1|.
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ [level 1/.style={sibling distance=20mm},
+ level 2/.style={sibling distance=5mm}]
+ \node {root}
+ child { child child }
+ child { child child child };
+\end{tikzpicture}
+\end{codeexample}
+\end{stylekey}
@@ -332,6 +347,8 @@ There are additional styles that influence how children are rendered:
\label{section-tree-placement}
+\subsubsection{Basic Idea}
+
Perhaps the most difficult part in drawing a tree is the correct
layout of the children. Typically, the children have different sizes
and it is not easy to arrange them in such a manner that not too much
@@ -360,6 +377,8 @@ tree grows can be changed globally and for parts of the tree. You can
even specify your own ``growth function'' to arrange children on a
circle or along special lines or curves.
+\subsubsection{Default Growth Function}
+
The default growth function works as follows: Assume that we are given
a node and five children. These children will be placed on a line with
their centers (or, more generally, with their anchors) spaced apart by
@@ -389,11 +408,9 @@ is given by the |level distance|.
\end{codeexample}
}
-Here is a detailed description of the options:
-\begin{itemize}
- \itemoption{level distance}|=|\meta{distance}
- This option allows you to change the distance between different
- levels of the tree, more precisely, between the parent and the line
+\begin{key}{/tikz/level distance=\meta{distance} (initially 15mm)}
+ This key determines the distance between different levels of the
+ tree, more precisely, between the parent and the line
on which its children are arranged. When given to a single child,
this will set the distance for this child only.
@@ -414,8 +431,8 @@ Here is a detailed description of the options:
\begin{codeexample}[]
\begin{tikzpicture}
- \tikzstyle{level 1}=[level distance=10mm]
- \tikzstyle{level 2}=[level distance=5mm]
+ [level 1/.style={level distance=10mm},
+ level 2/.style={level distance=5mm}]
\node {root}
child
child {
@@ -426,16 +443,18 @@ Here is a detailed description of the options:
child;
\end{tikzpicture}
\end{codeexample}
+\end{key}
- \itemoption{sibling distance}|=|\meta{distance}
- This option specifies the distance between the anchors of the
+\begin{key}{/tikz/sibling distance=\meta{distance} (initially 15mm)}
+ This key specifies the distance between the anchors of the
children of a parent node.
\begin{codeexample}[]
-\begin{tikzpicture}[level distance=4mm]
- \tikzstyle{level 1}=[sibling distance=8mm]
- \tikzstyle{level 2}=[sibling distance=4mm]
- \tikzstyle{level 3}=[sibling distance=2mm]
+\begin{tikzpicture}
+ [level distance=4mm,
+ level 1/.style={sibling distance=8mm},
+ level 2/.style={sibling distance=4mm},
+ level 3/.style={sibling distance=2mm}]
\coordinate
child {
child {child child}
@@ -449,14 +468,12 @@ Here is a detailed description of the options:
\end{codeexample}
\begin{codeexample}[]
-\begin{tikzpicture}[level distance=10mm]
- \tikzstyle{every node}=[fill=red!60,circle,inner sep=1pt]
- \tikzstyle{level 1}=[sibling distance=20mm,
- set style={{every node}+=[fill=red!45]}]
- \tikzstyle{level 2}=[sibling distance=10mm,
- set style={{every node}+=[fill=red!30]}]
- \tikzstyle{level 3}=[sibling distance=5mm,
- set style={{every node}+=[fill=red!15]}]
+\begin{tikzpicture}
+ [level distance=10mm,
+ every node/.style={fill=red!60,circle,inner sep=1pt},
+ level 1/.style={sibling distance=20mm,nodes={fill=red!45}},
+ level 2/.style={sibling distance=10mm,nodes={fill=red!30}},
+ level 3/.style={sibling distance=5mm,nodes={fill=red!25}}]
\node {31}
child {node {30}
child {node {20}
@@ -471,15 +488,17 @@ Here is a detailed description of the options:
child {node {20}
child {node {19}
child {node {1}}
- child[fill=none] {edge from parent[draw=none]}
+ child[missing]
}
child {node {18}}
};
\end{tikzpicture}
\end{codeexample}
-
- \itemoption{grow}|=|\meta{direction}
- This option is used to define the \meta{direction} in which the tree
+\end{key}
+
+
+\begin{key}{/tikz/grow=\meta{direction}}
+ This key is used to define the \meta{direction} in which the tree
will grow. The \meta{direction} can either be an angle in degrees or
one of the following special text strings: |down|, |up|, |left|,
|right|, |north|, |south|, |east|, |west|, |north east|,
@@ -556,21 +575,51 @@ Here is a detailed description of the options:
child[grow=100,<-] {node[above] {the middle is here}};
\end{tikzpicture}
\end{codeexample}
+\end{key}
- \itemoption{grow'}|=|\meta{direction}
- This option has the same effect as |grow|, only the children are
+\begin{key}{/tikz/grow'=\meta{direction}}
+ This key has the same effect as |grow|, only the children are
arranged in the opposite order.
+\end{key}
+
+
+\subsubsection{Missing Children}
+
+Sometimes one or more of the children of a node are ``missing.'' Such
+a missing child will count as a child with respect to the total number
+of children and also with respect to the current child count, but it
+will not be rendered.
+
+\begin{key}{/tikz/missing=\meta{true or false} (default true)}
+ If this option is given to a child, the current child counter is
+ increased, but the child is otherwise ignored. In particular, the
+ normal contents of the child is completely ignored.
+
+\begin{codeexample}[]
+\begin{tikzpicture}[level distance=10mm,sibling distance=5mm]
+ \node {root} [grow=down]
+ child { node {1} }
+ child { node {2} }
+ child { node {3} }
+ child[missing] { node {4} }
+ child { node {5} }
+ child { node {6} };
+\end{tikzpicture}
+\end{codeexample}
+\end{key}
+
- \itemoption{growth parent anchor}|=|\meta{anchor}
- This option allows you to specify which anchor of the parent node is
+\subsubsection{Custom Growth Functions}
+
+\begin{key}{/tikz/growth parent anchor=\meta{anchor} (initially center)}
+ This key allows you to specify which anchor of the parent node is
to be used for computing the children's position. For example, when
there is only one child and the |level distance| is |2cm|, then the
child node will be placed two centimeters below the \meta{anchor} of
the parent node. ``Beinng placed'' means that the child node's
anchor (which is the anchor specified using the |anchor=| option in
the |node| command of the child) is two centimeters below the parent
- node's \meta{anchor}. The default value of \meta{anchor} is
- |center|.
+ node's \meta{anchor}.
In the following example, the two red lines both have length |1cm|.
\begin{codeexample}[]
@@ -589,20 +638,25 @@ Here is a detailed description of the options:
In the next example, the top and bottom nodes are aligned at the top
and the bottom.
\begin{codeexample}[]
-\begin{tikzpicture}[level distance=2cm,growth parent anchor=north]
- \tikzstyle{every node}=[anchor=north,rectangle,draw]
- \tikzstyle{every child node}=[anchor=south]
+\begin{tikzpicture}
+ [level distance=2cm,growth parent anchor=north,
+ every node/.style={anchor=north,rectangle,draw}
+ every child node/.style={anchor=south}]
\node at (0,0) {root} child {node {small}};
\node at (2,0) {big root} child {node {\large big}};
\end{tikzpicture}
\end{codeexample}
+\end{key}
- \itemoption{growth function}|=|\meta{macro name}
+\begin{key}{/tikz/growth function=\meta{macro name} (initially
+ \normalfont an internal function)}
This rather low-level option allows you to set a new growth
function. The \meta{macro name} must be the name of a macro without
- parameters. This macro will be called for each child of a node.
+ parameters. This macro will be called for each child of a node. The
+ initial function is an internal function that corresponds to
+ downward growth.
The effect of executing the macro should be the following: It should
transform the coordinate system in such a way that the origin
@@ -621,7 +675,7 @@ Here is a detailed description of the options:
Additional growth functions are defined in the library, see
Section~\ref{section-tree-library}.
-\end{itemize}
+\end{key}
@@ -643,14 +697,14 @@ edge called the |edge from parent|. This edge is added to the
This operation has several effects. The most important is that it
inserts the current ``edge from parent path'' into the child
path. The edge from parent path can be set using the following
- option:
- \begin{itemize}
- \itemoption{edge from parent path}|=|\meta{path}
+ key:
+ \begin{key}{/tikz/edge from parent path=\meta{path} (initially
+ \normalfont code shown below)}
This options allows you to set the edge from parent path to a new
- path. The default for this path is the following:
- \begin{codeexample}[code only]
+ path. Initially, this path is the following:
+\begin{codeexample}[code only]
(\tikzparentnode\tikzparentanchor) -- (\tikzchildnode\tikzchildanchor)
- \end{codeexample}
+\end{codeexample}
The |\tikzparentnode| is a macro that will expand to the name of
the parent node. This works even when you have not assigned a name
to the parent node, in this case an internal name is automatically
@@ -678,19 +732,19 @@ edge called the |edge from parent|. This edge is added to the
Further useful edge from parent paths are defined in the tree
library, see Section~\ref{section-tree-library}.
-
- As said before, the anchors in the default edge from parent path
- are empty. However, you can set them using the following options:
- \begin{itemize}
- \itemoption{child anchor}|=|\meta{anchor}
- Specifies the anchor where the edge from parent meets the child
- node by setting the macro |\tikzchildanchor| to
- |.|\meta{anchor}.
-
- If you specify |border| as the \meta{anchor}, then the macro
- |\tikzchildanchor| is set to the empty string. The effect of
- this is that the edge from the parent will meet the child on the
- border at an automatically calculated position.
+ \end{key}
+
+ As said before, the anchors in the default edge from parent path
+ are empty. However, you can set them using the following keys:
+ \begin{key}{/tikz/child anchor=\meta{anchor} (initially border)}
+ Specifies the anchor where the edge from parent meets the child
+ node by setting the macro |\tikzchildanchor| to
+ |.|\meta{anchor}.
+
+ If you specify |border| as the \meta{anchor}, then the macro
+ |\tikzchildanchor| is set to the empty string. The effect of
+ this is that the edge from the parent will meet the child on the
+ border at an automatically calculated position.
\begin{codeexample}[]
\begin{tikzpicture}
\node {root}
@@ -702,25 +756,23 @@ edge called the |edge from parent|. This edge is added to the
};
\end{tikzpicture}
\end{codeexample}
- \itemoption{parent anchor}|=|\meta{anchor}
- This option works the same way as the |child anchor|, only for
- the parent.
- \end{itemize}
- \end{itemize}
+ \end{key}
+
+ \begin{key}{/tikz/parent anchor=\meta{anchor} (initially border)}
+ This option works the same way as the |child anchor|, only for
+ the parent.
+ \end{key}
Besides inserting the edge from parent path, the |edge from parent|
operation has another effect: The \meta{options} are inserted
directly before the edge from parent path and the following style is
also installed prior to inserting the path:
- \begin{itemize}
- \itemstyle{edge from parent}
+ \begin{stylekey}{/tikz/edge from parent (initially draw)}
This style is inserted right before the edge from parent path and
- before the \meta{options} are inserted. By default, it just draws
- the edge from parent, but you can use it to make the edge look
- different.
+ before the \meta{options} are inserted.
\begin{codeexample}[]
\begin{tikzpicture}
- \tikzstyle{edge from parent}=[draw,red,thick]
+ [edge from parent/.style={draw,red,thick}]
\node {root}
child {node {left} edge from parent[dashed]}
child {node {right}
@@ -729,7 +781,7 @@ edge called the |edge from parent|. This edge is added to the
};
\end{tikzpicture}
\end{codeexample}
- \end{itemize}
+ \end{stylekey}
Note: The \meta{options} inserted before the edge from parent path
is added \emph{apply to the whole child path}. Thus, it is not