# Feature diagram in LaTeX?

I would like to "translate" this diagram (a "feature model" or "feature diagram") into LaTeX. In particular, I didn't found how to draw arrows with a filled angle between them.

• Hi Florian and welcome to TeX.SX. In its current form, your question might not receive many answers. Please take a look at the How to Ask-page and try to improve your question according to the guidance found there. This may require you to show some effort on your part in terms of attempting a solution. If you have questions about what to do or if you don't quite understand what this means, please ask for clarification using the add comment function. Oct 24 '16 at 16:52
• Regarding the specific point of a filled angle between two arrows, have a look at TikZ's pic named... angle (cf. the example on §2.22 of the PGF manual - v.3.0.1a). Yup, it's a 1161 pages long PDF. And yup, each one of it is worth it. Oct 24 '16 at 19:32
• You can actually use ´matrix´ from tikz to create all the shapes of your diagram, which would make your diagram to be consistently aligned both among lines as well as among blocks. Then you can draw connecting the blocks. But I agree... You should put a little bit of effort into this, otherwise it´s very unlikely that you are going to get help. Oct 25 '16 at 10:45

Here an attempt with forest package and angles library to draw angles between edges

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{forest}
\usetikzlibrary{angles}

\begin{document}
\null
\vfill
\centering
\begin{forest}%
for tree={parent anchor=south,
child anchor=north,
l+=1cm,
fill=blue!30,
delay={content={\strut #1}},
},
blackcircle/.style={tikz={\node[fill=black!60,inner sep=3pt,circle]at(.north){};}},
whitecircle/.style={tikz={\node[draw,fill=white,inner sep=3pt,circle]at(.north){};}},
%
[Emergency Response System,fill=blue!10
[User interface,blackcircle]
[Inform emergency,blackcircle
[Inform Earthquake]
[Inform flood]
]
[Display neighborhood,blackcircle
[Map
[Display danger zone]
[Display safe zone]
[Display path to safe zone]
]
[Textual direction]
]
[Shortcut calls,whitecircle
[Cops]
[Ambulance]
[Fireman]
]
]
% fill angles
\foreach \i/\j/\k in {!21/!2/!22,!31/!3/!32,!41/!4/!43,!311/!31/!313}
{
\coordinate (A)at (\i.north);
\coordinate (O)at (\j.south);
\coordinate (B)at (\k.north);
\path  (A)--(O)--(B)
pic [fill=black!60, angle radius=4mm] {angle = A--O--B};
}
\end{forest}
\par
\vfill

\end{document}


In my opinion, I ought not answer do-it-for-me questions. Not even if somebody else has first.

It adapts some code I used to answer 3 similar questions earlier, which I do not currently have references for. (However, I guess it is OK not to attribute code I wrote in the first place anyhow.)

Basically, all of the fancy footwork is done by creating TikZ and Forest styles in the preamble of the document. Specifying the tree is then just a question of applying the styles and specifying a few parameters. Most of this is done in the tree's preamble i.e. after the forest environment starts but before the root node.

\begin{forest}


The main style:

  disjunction tree,


We want all nodes from level 1 onwards to get marked as disjunctions when the node has (multiple) children.

  disjuncts from'=1,


We want all nodes from level 1 onwards to be marked as concrete, rather than abstract.

  concrete from'=1,


Specify the colours for concrete and abstract nodes and the colour for drawing, outlining and filling angles and circles.

  concrete colour=blue!85!cyan!40,
abstract colour=blue!85!cyan!15,
draw colour=darkgray,


That's it. Now Salim Bou's specification of the tree. This is simplified a bit as we're styling most of it automatically. We do need to say when we want mandatory and optional markers to be used. We do this with mandatory and optional for the appropriate nodes.

  [Emergency Response System


Here come 2 mandatory disjuncts.

    [User interface, mandatory]
[Inform emergency, mandatory
[Inform Earthquake]
[Inform flood]
]


And a third.

    [Display neighbourhood, mandatory
[Map
[Display danger zone]
[Display safe zone]
[Display path to safe zone]
]
[Textual direction]
]


This one's optional.

    [Shortcut calls, optional
[Cops]
[Ambulance]
[Fireman]
]
]


And we're done. We don't need to mark the angles etc. manually as the disjunction tree style will do that, as well as creating a legend.

\end{forest}


Complete code:

\documentclass[border=10pt,tikz,multi]{standalone}
\usepackage{forest}
\forestset{
declare count register=disjuncts from,
disjuncts from'=0,
declare count register=concrete from,
concrete from'=2,
concrete colour/.code={\colorlet{concretecol}{#1}},
abstract colour/.code={\colorlet{abstractcol}{#1}},
draw colour/.code={\colorlet{drawcol}{#1}},
concrete colour=gray,
abstract colour=white,
draw colour=black,
/tikz/mandatory/.style={circle, fill=drawcol, draw=drawcol},
/tikz/optional/.style={circle, draw=drawcol, fill=white},
/tikz/concrete/.style={fill=concretecol, draw=drawcol},
/tikz/abstract/.style={fill=abstractcol, draw=drawcol},
/tikz/or/.style={},
mandatory/.style={edge label={node [mandatory] {}}},
optional/.style={edge label={node [optional] {}}},
or/.style={for first={disjunct}},
disjunct/.style={
tikz+={\path (.parent) coordinate (A) -- (!u.children) coordinate (B) -- (!ul.parent) coordinate (C) pic [fill=drawcol] {angle};}
},
disjunction tree/.style={
where={isodd(n_children())}{
for n={int((n_children()+1)/2)}{calign with current},
}{
calign=midpoint,
},
before typesetting nodes={
for nodewalk={
filter/.wrap pgfmath arg={{level>=##1}{n_children()>1}}{(disjuncts_from)}
}{
or,
},
where={level()>=(concrete_from)}{
concrete,
}{
abstract,
},
tikz+={
[font=\sffamily]
\node (l) [anchor=north west, xshift=10pt] at (current bounding box.north east) {Legend};
\foreach \i/\j [remember=\i as \k (initially l)] in {mandatory/Mandatory,optional/Optional,or/Or,abstract/Abstract,concrete/Concrete}
{
\node (\i) [below=20pt of \k.north, anchor=north, text centered, \i, minimum width=5pt,] {};
\node (\j) [right=15pt of \i.center -| mandatory.west, anchor=west] {\j};
};
\draw [drawcol] (or.south west) coordinate (A) -- (or.north) coordinate (B) -- (or.south east) coordinate (C) pic [fill=drawcol, angle radius=5pt] {angle};
\foreach \i in {mandatory,optional} \draw [darkgray] (\i.north east) -- +(45:5pt);
\node (c) [below=0pt of Concrete.south] {};
\scoped[on background layer]{\node [draw, fill=white, blur shadow, fit=(l) (Mandatory) (Optional) (Or) (Abstract) (Concrete) (c), rounded corners] {};}
},
},
for tree={
parent anchor=children,
child anchor=parent,
l'+=10mm,
rounded corners,
text height=2ex,
text depth=.5ex,
font=\sffamily,
},
},
}
\begin{document}
\begin{forest}% addaswyd o gôd Salim Bou: https://tex.stackexchange.com/a/335782/
disjunction tree,
disjuncts from'=1,
concrete from'=1,
concrete colour=blue!85!cyan!40,
abstract colour=blue!85!cyan!15,
draw colour=darkgray,
[Emergency Response System
[User interface, mandatory]
[Inform emergency, mandatory
[Inform Earthquake]
[Inform flood]
]
[Display neighbourhood, mandatory
[Map
[Display danger zone]
[Display safe zone]
[Display path to safe zone]
]
[Textual direction]
]
[Shortcut calls, optional
[Cops]
[Ambulance]
[Fireman]
]
]
\end{forest}
\end{document}