#StackBounty: #tikz-pgf #diagrams #tikz-trees #forest #trees Change alignment of tree-boxes in Block Diagram using Forest package (or o…

Bounty: 50

I need to draw a tree-like diagram for a classification purpose. Getting a cue from this question, I came up with the following MWE

documentclass{book}
usepackage[tmargin=2in, bmargin=2in, lmargin=1.5in, rmargin=1.5in]{geometry}
usepackage{showframe}
usepackage[edges]{forest}
usepackage{mathtools}
usepackage{amsmath}
usepackage{amsfonts}
usepackage{amssymb}
usepackage{varioref}
usepackage{cleveref}
usepackage{tikz}
usetikzlibrary{arrows.meta}
begin{document}
    begin{enumerate}
        item label{usual metric on R}
        item label{usual metric on C}
        item label{usual metric on R2}
        item label{5}
        item label{6}
        item label{16}
        item label{17}
        item label{C_int}
        item label{C_sup}
        item label{norm}
        item label{extended R}
        item label{extended C}
        item label{discrete}
        item label{d/(1+d)}
        item label{product metric}
    end{enumerate}
    begin{figure}[h!]
        centering
        begin{forest}
            for tree={draw,
                where level=1{minimum height=8ex,anchor=north}{},
                align=center,
                %           font=sffamily,
                edge+={thick, -{Stealth[]}},
                l sep'+=10pt,
                fork sep'=10pt,
            },
            forked edges,
            if level=0{
                inner xsep=0pt,
                tikz={draw [thick] (.children first) -- (.children last);}
            }{},
            [
            qquad Examples of metric spaces in this subsection qquad
            [
            Cref{usual metric on R,usual metric on C,usual metric on R2,5,6,16,17,C_int,C_sup,norm}:\
            Normed Linear Spaces
            [
            Cref{usual metric on R,usual metric on C,usual metric on R2,5,6}:\
            Finite dimensional\ vector spaces
            [Cref{5,6}:\ $ p $ metric and\ emph{sup} metric on $ mathbb{R}^{n} $]
            [Cref{usual metric on R,usual metric on C,usual metric on R2}:\ usual metrics on \ $ mathbb{R} $text{,} $ mathbb{C} $ and $ mathbb{R}^{2} $]
            ]
            [
            Cref{16,17}:\ Sequence spaces
            ]
            [
            Cref{C_int,C_sup}:\ Spaces of continuous \ functions
            ]
            ]
            [
            Cref{extended R,extended C}:\ Extended set of real\ and complex numbers
            ]
            [
            Cref{discrete}:\ Discrete metric
            ]
            [
            Cref{d/(1+d),product metric}:\ Derived metrics
            ]
            ]
        end{forest}
        caption{Examples of metric spaces in this subsection}
    end{figure}
end{document}

What I am looking for is to fit the diagram within the margin. For that, I want to left-align the boxes in the third and fourth level. Something like this:

enter image description here

How do I achieve this?

EDIT

To add more alternatives to achieve my goal, please consider the following options:

  1. the solution need not be using forest environment only. Any other way of giving the desired output is also welcome.

  2. In case it is easier, the following output also works for me as well:

enter image description here

Please help.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.