1

I'd like to merge level 4 nodes and align the single resulting node to the single node on level 1 (to have more symmetry).

here and here don't seem to answer my question.

enter image description here

MWE

\documentclass{standalone}
        \usetikzlibrary{
    fit,
    trees,
}

\begin{document}
\begin{tikzpicture}[
        level distance=1.5cm,align=center,
        level 1/.style={sibling distance=6cm,text width=3cm},
        level 2/.style={level 1,sibling distance=3cm},
        level 3/.style={level 2},
        level 4/.style={level 2},
    ]
    \node {Instruments} 
    child {node {Cash}
        child {node {Spot}
            child {node {\'Echange \\ Immédiat}
                child {node {Directement investissable}
                }
            }
        }
    }
    child {node (derivative) {Dérivés}
        child {node (term) {Terme}
            child {node (termdes) {\'Echange à \\ une date future}
            }
        }
        child {node (swap) {Swap}
            child {node (swapdes) {\'Echange de flux futurs suivant un calendrier}    
                child {node {Directement investissable} %% I create a child here for the example but I would actually have the fit area linked to the one child on level 4
                }
            }
        }
        child {node (option) {Option}
            child {node (optiondes){Variabilité future du sous-jacent}    
            }
        }
    };

    \node [fit=(termdes)(derivative)(swapdes.south)(optiondes),draw,dashed,rounded corners=5pt,fill=blue,opacity=0.2,label=right:Repackaging ]{};

\end{tikzpicture}
\end{document}
6
  • 1
    Would you consider a forest solution.
    – user194703
    Jun 7, 2020 at 2:17
  • @Schrödinger'scat I hardly use forest but your question seems to imply it's the simplest way. So yes.
    – JeT
    Jun 7, 2020 at 4:46
  • 1
    To be honest, I am not sure I understand how the target output should look like. Do you want to make the tree wider? (And yes, forest is often more powerful and user friendly.)
    – user194703
    Jun 7, 2020 at 4:51
  • @Schrödinger'scat I am far from my computer to give you another visual. But the tree recombines on level 4. The node on level 4 is horizontally aligned with the node at level 1 (so in my example for it should be below "échange à une date future")
    – JeT
    Jun 7, 2020 at 5:05
  • 1
    So the two nodes Directement investissable should become one?
    – user194703
    Jun 7, 2020 at 5:10

1 Answer 1

2

Maybe like this?

\documentclass[tikz]{standalone}
\usetikzlibrary{
    fit,
    trees,
}

\begin{document}
\begin{tikzpicture}[
        level distance=1.5cm,align=center,
        level 1/.style={sibling distance=6cm,text width=3cm},
        level 2/.style={level 1,sibling distance=3cm},
        level 3/.style={level 2},
        level 4/.style={level 2,level distance=2.5cm},
    ]
    \node (ins){Instruments} 
    child {node {Cash}
        child {node {Spot}
            child {node(EI) {\'Echange \\ Imm\'ediat}
%                 child {node {Directement investissable}
%                 }
            }
        }
    }
    child {node (derivative) {D\'eriv\'es}
        child {node (term) {Terme}
            child {node (termdes) {\'Echange \'a \\ une date future}
                child {node(DI) {Directement investissable} %% I create a child here for the example but I would actually have the fit area linked to the one child on level 4
                }
            }
        }
        child {node (swap) {Swap}
            child {node (swapdes) {\'Echange de flux futurs suivant un calendrier}    
            }
        }
        child {node (option) {Option}
            child {node (optiondes){Variabilit\'e future du sous-jacent}    
            }
        }
    };

    \node [fit=(termdes)(derivative)(swapdes.south)(optiondes),draw,dashed,rounded corners=5pt,fill=blue,opacity=0.2,label=right:Repackaging ]{};
    \draw (DI) edge (EI) edge (swapdes) edge (optiondes);
\end{tikzpicture}
\end{document}

enter image description here

Or

\documentclass[tikz]{standalone}
\usetikzlibrary{
    fit,
    trees,
}

\begin{document}
\begin{tikzpicture}[
        level distance=1.5cm,align=center,
        level 1/.style={sibling distance=6cm,text width=3cm},
        level 2/.style={level 1,sibling distance=3cm},
        level 3/.style={level 2},
        %level 4/.style={level 2,level distance=2.5cm},
    ]
    \node (ins){Instruments} 
    child {node {Cash}
        child {node {Spot}
            child {node(EI) {\'Echange \\ Imm\'ediat}
%                 child {node {Directement investissable}
%                 }
            }
        }
    }
    child {node (derivative) {D\'eriv\'es}
        child {node (term) {Terme}
            child {node (termdes) {\'Echange \'a \\ une date future}
%                 child {node(DI) {Directement investissable} %% I create a child here for the example but I would actually have the fit area linked to the one child on level 4
%                 }
            }
        }
        child {node (swap) {Swap}
            child {node (swapdes) {\'Echange de flux futurs suivant un calendrier}    
            }
        }
        child {node (option) {Option}
            child {node (optiondes){Variabilit\'e future du sous-jacent}    
            }
        }
    };
    \path (current bounding box.south) node[below=1cm,text width=3cm]
        (DI) {Directement investissable};
    \node [fit=(termdes)(derivative)(swapdes.south)(optiondes),draw,dashed,rounded corners=5pt,fill=blue,opacity=0.2,label=right:Repackaging ]{};
    \draw (DI) edge (EI) edge (termdes) edge (swapdes) edge (optiondes);
\end{tikzpicture}
\end{document}

enter image description here

2
  • @schrodingerscat exactly. So the extra node has to be connected manually OK! Merci :)
    – JeT
    Jun 7, 2020 at 5:19
  • 2
    @JeT I think this is the case.
    – user194703
    Jun 7, 2020 at 5:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .