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.

Following the examples in the documentation, it is not too difficult to customize the edge of trees using the tikz-qtree package. The following code illustrates it:

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

\begin{document}

\begin{tikzpicture}
  \tikzset{
    edge from parent/.style={
      draw,
      edge from parent path={
        (\tikzparentnode.south) -- (\tikzparentnode.south |- 0,-10pt -| \tikzchildnode) -- (\tikzchildnode)
      }
    }
  }
  \Tree [.ZZ
          [.Bax
            [.X
              [.Y [.A ] [.B ] ]
              [.Z [.C ] [.D ] ] ]
            [.F
              [.M [.E ] [.F ] ]
              [.G [.G ] [.H ] ] ] ]
          [.A
            [.B
              [.S  [.I P R T V U ] [.J ] ]
              [.I  [.K ] [.L ] ] ]
            [.M
              [.L  [.M ] [.N ] ]
              [.A  [.O ] [.P ] ] ] ] ]
\end{tikzpicture}

\end{document}

Its output is:

output of the example document

How can the same style of edges used in this example be accomplished with the forest package?

share|improve this question
    
Should be as simple as in Square edges in forest package –  Qrrbrbirlbel Jul 6 '13 at 3:12
    
@Qrrbrbirlbel yes, it should be as simple as the other example. But I am not succeeding with it. –  Romildo Jul 6 '13 at 3:18
    
Honestly, I never understood tikz-qtree correctly (something similar to what I experienced another time), as it somehow seems to understand 0,-10pt relatively. –  Qrrbrbirlbel Jul 6 '13 at 3:22

1 Answer 1

up vote 6 down vote accepted

While I still wonder about (\tikzparentnode.south |- 0,-10pt -| \tikzchildnode), the approach in usual TikZ (and forest) is even a little bit more comprehensible (for me at least):

edge path={\noexpand\path[\forestoption{edge}] 
                (\forestOve{\forestove{@parent}}{name}.parent anchor)
             -- ([shift={(0,-10pt)}]
                         \forestOve{\forestove{@parent}}{name} -| \forestove{name})
             -- (\forestove{name}.child anchor)
                \forestoption{edge label};
          }

The kink of the line is shifted 10pt downwards from parent -| child.

Code

\documentclass[tikz,convert=false]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
  for tree={%
    % re-establishing the defaults:
    child anchor=north,
    parent anchor=south,
    edge path={\noexpand\path[\forestoption{edge}] 
                    (\forestOve{\forestove{@parent}}{name}.parent anchor)
                 -- ([shift={(0,-10pt)}]
                             \forestOve{\forestove{@parent}}{name} -| \forestove{name})
                 -- (\forestove{name}.child anchor)
                    \forestoption{edge label};
              }
  }
 [ZZ
 [Bax
 [X
 [Y [A ] [B ] ]
 [Z [C ] [D ] ] ]
 [F
 [M [E ] [F ] ]
 [G [G ] [H ] ] ] ]
 [A
 [B
 [S  [I [P][R][T][V][U]] [J ] ]
 [I  [K ] [L ] ] ]
 [M
 [L  [M ] [N ] ]
 [A  [O ] [P ] ] ] ] ] ]
\end{forest}
\end{document}

Output

enter image description here

share|improve this answer

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.