2 minute read

I was trying to draw a taxonomy like tree where the child nodes are aligned to the right rather than bottom. It is for drawing a literature survey alike tree, which looks like following:


To draw a taxonomy tree like this, first, we need the following packages:


Now, here’s the code that produces this output. You can also check out the output in this overleaf project.

% I am using only the basic, xnode, and tnode styles
    basic/.style  = {draw, text width=3cm, align=center, font=\sffamily, rectangle},
    root/.style   = {basic, rounded corners=2pt, thin, align=center, fill=green!30},
    onode/.style = {basic, thin, rounded corners=2pt, align=center, fill=green!60,text width=3cm,},
    tnode/.style = {basic, thin, align=left, fill=pink!60, text width=15em, align=center},
    xnode/.style = {basic, thin, rounded corners=2pt, align=center, fill=blue!20,text width=5cm,},
    wnode/.style = {basic, thin, align=left, fill=pink!10!blue!80!red!10, text width=6.5em},
    edge from parent/.style={draw=black, edge from parent fork right}


\begin{forest} for tree={
    growth parent anchor=west,
    parent anchor=east,
    child anchor=west,
    edge path={\noexpand\path[\forestoption{edge},->, >={latex}] 
         (!u.parent anchor) -- +(10pt,0pt) |-  (.child anchor) 
         \forestoption{edge label};}
% l sep is used for arrow distance
[Reconnaissance Survey, basic,  l sep=10mm,
    [Network Scanning, xnode,  l sep=10mm,
        [Shaikh et al.\, 2008, tnode]
        [Bhuyan et al.\, 2011, tnode]
        [Bou et al.\, 2013, tnode] ]
    [Social Engineering, xnode,  l sep=10mm,
        [Chiew et al.\, 2018, tnode]
        [Heartfield \& Loukas\, 2015, tnode]
        [Salahdine et al.\, 2019, tnode] 
        [Alharthi et al.\, 2020, tnode] ]
    [Open-Source Footprinting, xnode,  l sep=10mm,
        [Rai et al.\, 2021, tnode]
        [Kanta et al.\, 2020, tnode]
        [Glassman et al.\, 2012, tnode] 
         ] ]

    \caption{Literature Survey Tree}

There are a few node styles defined earlier in the code. However, I am using only the basic, xnode, and tnode styles. you can change the designs of the node by changing the parameters like align, fill, etc.

Then under the \begin{forest}...\end{forest} environment, all you need to do is create a python list-alike array of contents, where you put child nodes as a nested list.

You can also check out my other post: Draw a Taxonomy Tree in Latex using Tikz for Publication.

You can find a comprehensive list of Latex resources in the following post:

Latex Resources in a Nutshell

If you are a new Latex user, check out this post: 20 Most Common Mistakes Made by New Latex Users

You can find all Latex oriented posts of mine in: https://shantoroy.com/categories/#latex

Leave a comment