Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a Tikz graph that looks something like this:

\usepackage{tikz}
\usetikzlibrary{shapes,positioning,shadows,arrows}

...

\begin{tikzpicture}[
    singleNode/.style={rectangle, draw=none, rounded corners=1mm, fill=green, drop shadow,
        text centered, anchor=north},
    subtree2/.style={regular polygon, regular polygon sides=3, draw=none, fill=blue,
        drop shadow, text centered, anchor=north, minimum height=6em},
    subtree3/.style={regular polygon, regular polygon sides=3, draw=none, fill=blue,
        drop shadow, text centered, anchor=north, minimum height=9em},
    level distance=1em, growth parent anchor=south
]
    \node (k3) [singleNode] {$k_3$} [sibling distance=20em]
    child{ [sibling distance=14em]
        node (k1) [singleNode] {$k_1$}
        child{
            node (A) [subtree3] {$A$}
        }
        child{ [sibling distance=8em]
            node (k2) [singleNode] {$k_2$}
            child{
                node (B) [subtree3, fill=red] {$B$}
            }
            child{
                node (C) [subtree2] {$C$}
            }
        }
    }
    child{
        node (D) [subtree3] {$D$}
    }
;
\end{tikzpicture}

subtree2 and subtree3 represent subtrees of height 2 and 3, respectively. This graph looks almost as I intend it, but the edge from a parent to a subtree connects at the side of the triangle, rather than the top.

How can I specify that the edge should connect to the top of my triangles?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

I think what you want is something like

edge from parent path={(\tikzparentnode.south) -- (\tikzchildnode.north)}

in the options to the tikzpicture. See the section on "Edges From the Parent Node" in the TiKZ manual to see some more examples of what you can do with this. (As it stands, this will give the edges from the parents to the children a very shallow slope; you can rectify this perhaps by having the children descend further from the parents.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.