Liebes Forum, ich habe eine Frage zur Erstellung von Baeumen. Ich habe es bereits geschafft, meinen Baum zu Erstellen, bin auch recht zufrieden damit, brauche aber jetzt noch eine vertikale, gestrichelte Linie zwischen den beiden Knoten B und C. Weiss vielleicht jemand, ob das moeglich ist und wenn ja, wie? Mein bisheriger Code sieht wie folgt aus: Open in writeLaTeX
\documentclass[12pt, a4paper, bibliography=totoc, abstracton]{scrartcl} \usepackage{tikz} \usetikzlibrary{trees} \begin{document} \begin{figure} % Set the overall layout of the tree \tikzstyle{level 1}=[level distance=3.5cm, sibling distance=3.5cm] \tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm] % Define styles for bags and leafs \tikzstyle{bag} = [text width=4cm, text centered, inner sep=1pt] \tikzstyle{end} = [circle, minimum width=3pt,fill, inner sep=0pt] \begin{tikzpicture}[grow=right, sloped] \tikzset{frontier/.style={distance from root=150pt}} \node {A} child { node[bag] {C} child { node[end, label=right: {$G (2,2)$}] {} edge from parent node[above] {} node[below] {$s_{22}$} } child { node[end, label=right: {$F (4,1)$}] {} edge from parent node[above] {$s_{21}$} node[below] {} } edge from parent node[above] {} node[below] {$s_{12}$} } child { node[bag] {B} child { node[end, label=right: {$E (1,4)$}] {} edge from parent node[above] {} node[below] {$s_{22}$} } child { node[end, label=right: {$D (3,3)$}] {} edge from parent node[above] {$s_{21}$} node[below] {} } edge from parent node[above] {} node[below] {$s_{12}$} }; \end{tikzpicture} \end{figure} \end{document} Vielen Dank im Voraus. Liebe Gruesse, Katja. gefragt 19 Aug '14, 17:04 KatjaBachelo... esdd |
Solch eine Verbindung ist in einem Baum nicht vorgesehen. Deshalb muss man sie von Hand reinmalen indem man die entsprechenden Nodes benennt und dann mittels Bitte verwende in Zukunft Open in writeLaTeX
\documentclass{article} \usepackage{tikz} \usetikzlibrary{trees} \begin{document} \begin{figure} \tikzset{ % Set the overall layout of the tree level 1/.style = {level distance=3.5cm, sibling distance=3.5cm}, level 2/.style = {level distance=3.5cm, sibling distance=2cm}, % Define styles for bags and leafs bag/.style = {text width=4cm, text centered, inner sep=1pt}, end/.style = {circle, minimum width=3pt,fill, inner sep=0pt} } \begin{tikzpicture}[grow=right, sloped] \tikzset{frontier/.style={distance from root=150pt}} \node {A} child { node[bag] (C) {C} child { node[end, label=right: {$G (2,2)$}] {} edge from parent node[above] {} node[below] {$s_{22}$} } child { node[end, label=right: {$F (4,1)$}] {} edge from parent node[above] {$s_{21}$} node[below] {} } edge from parent node[above] {} node[below] {$s_{12}$} } child { node[bag] (B) {B} child { node[end, label=right: {$E (1,4)$}] {} edge from parent node[above] {} node[below] {$s_{22}$} } child { node[end, label=right: {$D (3,3)$}] {} edge from parent node[above] {$s_{21}$} node[below] {} } edge from parent node[above] {} node[below] {$s_{12}$} }; \draw[dashed,shorten <=4pt,shorten >=4pt] (B) -- (C); \end{tikzpicture} \end{figure} \end{document} Mit
|
Hallo Katja, herzlich willkommen auf der TeXwelt! Prima, dass Du gleich konkreten Code mitbringst.