2

How can I increase level separation to keep the tree nodes aligned when the node texts include the line breaks? l sep seems to have no effect.

\documentclass{article}
\usepackage{forest}

\begin{document}

\begin{forest} 
for tree={
    for tree={draw=black,align=center,l sep=6em},
  edge path={
    \noexpand\path[\forestoption{edge}]
      (!u.parent anchor) -- +(0,-15pt) -|   
      (.child anchor)\forestoption{edge label};
  },
  l sep=10pt,
}
[P\\1\\2
  [N1\\1\\2,name=_N1
    [N1C1\\1\\2]
    [N1C2,name=_N2]
  ]
  [N2
    [N2C1]
    [N2C2]
  ]
]
\end{forest}

\end{document}

enter image description here

1

I just introduced some phantom text. I also changed the anchor depth.

\documentclass{article}
\usepackage{forest}

\begin{document}

\begin{forest} 
for tree={
    for tree={draw=black,align=center,l sep=6em},
  edge path={
    \noexpand\path[\forestoption{edge}]
      (!u.parent anchor) -- +(0,-25pt) -|   
      (.child anchor)\forestoption{edge label};
  },
  l sep=10pt,
}
[P\\1\\2
  [N1\\1\\2,name=_N1
    [N1C1\\1\\2]
    [N1C2,name=_N2]
  ]
  [N2\\~\\~,name=N2
    [N2C1]
    [N2C2]
  ]
]
\end{forest}

\end{document}

enter image description here

  • Having 2 l sep caused the issue I think as one was overriding another. – ajeh Jun 6 '14 at 15:19
  • If you would like me to delete my answer, just let me know that you've solved the issue through other means. – Steven B. Segletes Jun 6 '14 at 15:45

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.