2

I am making a tree with package forest. This is so far what I've tried from the example in the documentation -

\documentclass{standalone}
\usepackage[edges]{forest}

\begin{document}
\begin{forest}
for tree={grow=south,draw},
forked edges,
[[First node][Second node[Third node][Fourth node[Fifth node][Sixth node]]]]
\end{forest}
\end{document}

If we look at the output of it, the first node has a box in which nothing is there. I don't want that box, but I want the line below the box. How to achieve this?

5

You can add draw=none to specific nodes to overrule the draw that applies to all nodes (because it is set in for tree).

\documentclass{standalone}
\usepackage[edges]{forest}

\begin{document}
\begin{forest}
for tree={grow=south,draw},
forked edges,
[,draw=none
 [First node]
 [Second node
  [Third node]
  [Fourth node
   [Fifth node]
   [Sixth node]
  ]
 ]
]
\end{forest}
\end{document}

enter image description here

  • Exactly what I wanted. What was the key? I suppose [,draw=none made the change, right? – Niranjan Oct 24 at 7:54
  • 1
    @Niranjan Yes, that's correct. – Schrödinger's cat Oct 24 at 7:58
  • 1
    @Niranjan The reason it happens is because you have for tree= ... draw, which draws the border of all nodes. You could just not draw this one, so you wouldn't have to cancel it. Or you could test and only draw nodes with content. Alternatively, you might want to use coordinate for empty nodes, so they don't take up spurious space (or you may not, if the space isn't spurious). – cfr Oct 24 at 23:18

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.