6

I am trying to produce a binary tree using Tikz-qtree, however I am trying to figure out a way to shift my leaf node so that the top of the triangle connects to the edge. I tried using yshift on the node itself, but the edge is still connected to the same position.

The following code:

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{positioning,babel,shadows,trees,backgrounds,fit,arrows,shapes.geometric}   


\begin{document}

\tikzset{every tree node/.style={minimum size=10mm,inner sep=0pt,draw,circle, line width=1mm,font=\Large},
         edge from parent/.style=
         {draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}},
         level distance=2cm, sibling distance=.5cm}




\begin{tikzpicture}
\Tree [.~ \node[inner sep=10pt, regular polygon, regular polygon sides=3]{~}; \node[inner sep=10pt, regular polygon, regular polygon sides=3](b1){~}; ] 
\end{tikzpicture}

\end{document}

produces this image: enter image description here

However, I want to change it to something like this: enter image description here

3
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Commented Jul 10, 2017 at 5:43
  • Use Forest with child anchor=parent (or child anchor=north` for older versions).
    – cfr
    Commented Jul 11, 2017 at 20:22
  • @MartinSchröder The OP seems to be doing pretty well with the format. Looks like a fine first post to me. [I know this is a standard comment, but it carries the implication 'you obviously aren't familiar with our format', which is OK if true, but confusing, if not.]
    – cfr
    Commented Jul 11, 2017 at 20:24

1 Answer 1

6

You can change the edge from parent path option to:

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

to obtain:

output

(probably it will look better if you move your triangles nodes a bit further down).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .