# Drawing a “feature tree” with PSTricks or Tikz

I know that Tikz and PSTricks both offer many packages and options to draw trees, but I have no clue how I would go about drawing a feature tree as seen in Karl Wiegers guide Software Requirements (Microsoft Press, 2013), since it is not really one single tree but essentially tree little trees connected by a straight line, itself being connected to an ellipse. Can anyone lend me a hand?

• Welcome! Can you provide what you've got so far? Even if you just provide a document with some placeholders for somebody to put into a tree format, it makes it easier for people to answer. – cfr Feb 21 '17 at 11:12
• It is a tree. I guess. If you think of the ellipse as the root, the tree grows left (main direction of growth) and then branches out (changed directions of growth). But it matters, too, how much like this you need it. What about this diagram is crucial and what not? (It looks rather messy to me, but is that by design?) – cfr Feb 21 '17 at 11:13
• Why is Chemical tracking system on the right, since that seems to be the overall concept? Wouldn't it be move logical to have it on the left or at the top? – cfr Feb 21 '17 at 11:16
• Hi @cfr, Honestly I haven't even tried to implement it, because I didn't have a clue how to start. So I'll have to think about it. Let met try implementing it myself first. – TexNoob Feb 21 '17 at 12:22
• As I say, even providing some content people can move around is helpful. Copying or approximating text from images when you don't know the topic is a pain. (And if you make it too different, it doesn't necessarily work correctly with the real content e.g. if there are lots more nodes or the content of nodes is much longer/shorter or something.) – cfr Feb 21 '17 at 12:29

Instead of using a tree library with complicated nesting syntax and restrictions, relying on automatic positioning, I would use the standard TikZ syntax in a handy way.

• Define styles for different kinds of nodes
• Place main coordinates, use calc syntax to divide distances
• Place the main nodes at those coordinates
• Place further nodes, as it's visually nice, try using relative positioning
• Draw connecting lines

Since relative positioning and using calculations is logic positioning, all stays well in place when you tweak some values to finish.

The main part - remaining nodes can be added in a similar way:

\documentclass[tikz,border=4mm]{standalone}
\usetikzlibrary{calc,shapes,positioning}
\tikzset{%
root/.style = { draw, ellipse, fill=blue!10,
font = \sffamily\LARGE\bfseries, align = center},
main/.style = { draw, rounded corners = 6pt, fill=blue!10, align = center,
font = \sffamily\Large\bfseries, minimum height = 11ex,
inner sep = 6pt},
end/.style  = { font = \sffamily\bfseries},
}
\newcommand*{\len}{18}
\begin{document}
\begin{tikzpicture}

% Base graph coordinates
\coordinate (A);
\coordinate (B) at ($(A)+(\len,0)$);
\coordinate (D) at ($(A)!.4!(B)$);
\coordinate (E) at ($(A)!.7!(B)$);
\coordinate (F) at ($(D)!.5!(E)$);

% main leaves coordinates
\coordinate (health) at ($(D)+(120:\len/3)$);
\coordinate (order) at ($(E)+(120:\len/3)$);
\coordinate (inventory) at ($(F)+(240:\len/3)$);

% graph lines
\draw (A) -- (B)
(D) -- (health)
(E) -- (order)
(F) -- (inventory);

% root node
\node [root] at (B) {Chemical\\Tracking\\System};

% main leaves nodes
\node [main, above = 0 of health] {Health \&\\Safety};
\node [main, above = 0 of order] {Order\\Chemicals};
\node [main, below = 0 of inventory] {Inventory\\Management};

% end leaves nodes, positioning in relation to existing nodes
% somehow manually, but relative positioning makes changes easier
\node (info)       [end, anchor=west] at ($(A)+(0,0.2*\len)$) {Health \& Safety Info};
\node (compliance) [end, anchor=west] at ($(A)!.6666!(info.west)$) {Compliance Reporting};
\node (exposure)   [end, anchor=west] at ($(A)!.3333!(info.west)$) {Chemical Exposure Report};

\node (laboratories) [end, anchor=west] at ($(A)-(0,0.1*\len)$) {Laboratories};
\node (stockroom) [end, anchor=west] at ($(A)!.5!(laboratories.west)$) {Chemical Stockroom};

\node (incident)  [end] at ($(health)!.6666!(order)-(0,1)$) {Incident Reporting};
\node (request)   [end] at ($(incident)!.4!(F)$) {Chemical Request};
\node (receiving) [end] at ($(inventory)!.5!(E)+(1,0)$) {Receiving};
\node (search)    [end] at ($(order)!.5!(B)+(1,1)$) {Search};

% draw lines
\draw (info.east) -- ($(health)!(info.east)!(D)$);
\draw (compliance.east) -- ($(health)!(compliance.east)!(D)$);
\draw (exposure.east) -- ($(health)!(exposure.east)!(D)$);
\draw (incident.west) -- ($(health)!(incident.west)!(D)$);

\draw (request.east) -- ($(order)!(request.east)!(E)$);
\draw (stockroom.east) -- ($(inventory)!(stockroom.east)!(F)$);
\draw (laboratories.east) -- ($(inventory)!(laboratories.east)!(F)$);
\draw (receiving.west) -- ($(inventory)!(receiving.west)!(F)$);

\draw (search.west) -- ($(order)!(search.west)!(E)$);

\end{tikzpicture}
\end{document}