2

How can I change the style of all the edges in code below like the red one? I tried adding every edge/.style={..} but it doesn't work.

\documentclass{article}
\usepackage{tikz-qtree}

\begin{document}        

\begin{tikzpicture}[every tree node/.style={font=\huge},
level distance=1.1cm,sibling distance=.8cm, 
edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode)}],
frontier/.style={distance from root=350pt} % Align leaf nodes

\Tree 
[
\edge [ultra thick, dashed,red] node[black,near end,left] {branch};
[   
\edge node[near end, left] {};
[
\edge node[] {}; [.a ]
\edge node[] {}; [.b ]        
]        
\edge node[] {}; [.c ]
]
\edge node[near end,right] {};
[   
\edge node[] {}; [.d ]
\edge node[] {}; [.e ]
]
]
\end{tikzpicture}

\end{document}

enter image description here

1 Answer 1

4

You can do it like this:

\documentclass{article}
\usepackage{tikz-qtree}

\begin{document}        

\begin{tikzpicture}[every tree node/.style={font=\huge},edge from parent/.style={draw,red,ultra thick,dashed},
level distance=1.1cm,sibling distance=.8cm, 
edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode)}],
frontier/.style={distance from root=350pt} % Align leaf nodes

\Tree 
[
\edge  node[black,near end,left] {branch};
[   
\edge node[near end, left] {};
[
\edge node[] {}; [.a ]
\edge node[] {}; [.b ]        
]        
\edge node[] {}; [.c ]
]
\edge node[near end,right] {};
[   
\edge node[] {}; [.d ]
\edge node[] {}; [.e ]
]
]
\end{tikzpicture}

\end{document}

Output:

enter image description here

I found it here:

https://tex.stackexchange.com/a/9242/120578

I just change it for every edge. But it is almost a duplicate... Let others decide (I will not mark it because it is different question even if the answer is there)

1
  • 1
    Order matters! i.e. if we use edge from parent/.style={draw,red,ultra thick,dashed}, after edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode)}],, then the style won't apply (idk why)
    – havij
    Oct 13, 2017 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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