# forest: Draw a roof over multiple children in forest?

I often want to draw schematic trees like the following.

These don't work with the current roof option in forest because I often need the roof to extend over multiple nodes.

It looks like the current roof code draws the roof as an edge path from the child upwards, meaning that the base of the roof only ever covers one node:

\forestset{
roof/.style={edge path'={%
(.parent first)--(!u.children)--(.parent last)--cycle
}
},
}


Is there some simple/elegant way to get a roof to cover multiple nodes?

Edited to add a MnWE (minimal non-working example)

Here's the best I can do right now:

\documentclass{article}
\usepackage[linguistics]{forest}

\begin{document}

\begin{forest}
[XP,
[node1]
[YP, roof % triangle will be drawn between YP and XP
[node2, roof] % triangle will be drawn between node2 and YP
]
]
\end{forest}

\end{document}


Ideally it would be nice to have some kind of modifier like downroof to draw triangles from a parent down to all the immediate children, like this:

\begin{forest}
[XP, downroof % ideally will draw triangle to cover node1 and YP
[node1]
[YP, downroof % ideally will draw triangle to cover node2
[node2]
]
]
\end{forest}

• Fair. They seemed linked when I first asked the question; by the time I finished editing the question they didn't so much. I think I may edit to delete the spacing issue. – Natalie Weber Dec 16 '17 at 6:02
• You could ask a new question for the spacing issue, but I think it would be best if you could explain what exactly you want a solution to do. The downroof question was admirably clear. Of course, sometimes what you want can't be done or someone has a better idea, but, even then, it's helpful as a starting point. In this case, too, it was possible to do exactly what you wanted very straightforwardly (unless I've misunderstood), so that clarity was perfect. – cfr Dec 16 '17 at 16:39
• Nah, I think deleting was best precisely because I don't have an idea for a solution. What's wrong with faking space with an \hbox like I've been doing? Nothing, and I don't think the default behavior is a bug. It was a poorly asked question. :) – Natalie Weber Dec 16 '17 at 18:26

downroof draws a roof spanning all of a node's children:

\documentclass[border=10pt]{standalone}
\usepackage[linguistics]{forest}
\forestset{
downroof/.style={
for children={
if n=1{
edge path'={
(.parent first) -- (!u.parent anchor) -- (!ul.parent last) -- cycle
}
}{no edge}
}
}
}
\begin{document}
\begin{forest}
[XP, downroof % ideally will draw triangle to cover node1 and YP
[node1]
[YP, downroof % ideally will draw triangle to cover node2
[node2]
]
]
\end{forest}
\end{document}


• I wanted to wait before accepting in case other answers came in, but since this does exactly what I want, I can't imagine there's going to be a better one... Thanks very much! – Natalie Weber Dec 16 '17 at 18:27
• @NatalieWeber It is no problem if you want to wait. I hope I didn't say anything to suggest you should accept this! I just thought the questions should be separate. I didn't mean you should accept my answer to this one. – cfr Dec 17 '17 at 1:57