LaTeX

TikZ Tree에 설명 달기

ForceCore 2009. 4. 19. 02:02
Node의 옆에 설명을 달고싶을 때가 있다. 그럴 때엔 이렇게 한다...



코드:

\begin{tikzpicture}[

%every node/.style={c},

level distance=15mm,

level 1/.style={sibling distance=30mm},

level 2/.style={sibling distance=15mm},

level 3/.style={sibling distance=15mm}

]

%\usetikzlibrary{shapes}

\tikzstyle{c} = [draw, shape=circle]

%\tikzstyle{tr} = [draw, isosceles triangle, shape border rotate=90, anchor=north]

\node{}[edge from parent]

child{

node[c] (n1) {$n_1$}

child {

node[c] (n2) {$n_2$}

}

child[child anchor=north] {

node[c] (n3) {$n_3$}

}

};

\node at ([xshift=30mm] n1) {$f(n_1) = f(n_2) + f(n_3)$};

\node at ([xshift=-12mm] n2) {$f(n_2)$};

\node at ([xshift=12mm] n3) {$f(n_3)$};

\end{tikzpicture}

Node의 위치를 variable로 줄 수 있으며 그 offset을 줄 수 있다... 물론 매뉴얼에도 나온 기능이지만...