Arrow Styles In TikZ Trees


Answer :

There are easier ways to draw trees, but if you wish to stick to TikZ's verbosity, you can override the style with another.

\documentclass[border=9pt]{standalone} \usepackage[]{tikz}  \begin{document} \tikzset{   breakarrow/.style={->, dashed},   myarrow/.style={solid, -},   varnode/.style = {shape=rectangle, rounded corners,     draw, align=center,     top color=red!20, bottom color=white} }  \begin{tikzpicture}[sibling distance=6em, every node/.style = {shape=rectangle, rounded corners, draw, align=center, top color=white, bottom color=violet!20}]   \node {/}   child { node {tmp/}}   child { node {initrd.img}}   child { node {usr/}     child { node {local/}}     child { node {lib/}}     child { node [varnode] {$\alpha_{/usr}$} edge from parent [breakarrow]}}; \end{tikzpicture} \begin{tikzpicture}[sibling distance=6em, every node/.style = {shape=rectangle, rounded corners, draw, align=center, top color=white, bottom color=violet!20}]   \node [varnode] {$\alpha_{/usr}$}   child { node {share/} edge from parent [breakarrow]}   child { node {bin/}  edge from parent [breakarrow]     child { node {cat} edge from parent [myarrow]}     child { node [varnode] {$\beta_{/usr/bin}$} edge from parent [breakarrow]}     child { node {tac} edge from parent [myarrow]}}; \end{tikzpicture} \begin{tikzpicture}[sibling distance=6em, every node/.style = {shape=rectangle, rounded corners, draw, align=center, top color=white, bottom color=violet!20}]   \node [varnode] {$\beta_{/usr/bin}$}   child { node {col} edge from parent [breakarrow]}; \end{tikzpicture} \end{document} 

override one style with another

I would instead do the following:

\documentclass[border=9pt]{standalone} \usepackage[]{forest}  \begin{document} \forestset{   break arrow/.style={edge+={->, dashed}},   my base node/.style={rounded corners, draw, align=center,},   var node/.style = {my base node, top color=red!20, bottom color=white},   my node/.style={my base node, top color=white, bottom color=violet!20,}, } \begin{forest}   for tree={my node, s sep'=3em, l sep'+=1em, }   [$\alpha_{/usr}$, var node     [share/]     [bin/, break arrow       [cat]       [$\beta_{/usr/bin}$, var node, break arrow]       [tac]     ]   ] \end{forest} \end{document} 

Forest solution

Then you don't have to override anything and can apply styles precisely to the edges and nodes you want.


Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer