2

I want to make something like the following image in tikz:

sketch

To be able to do this, I would need to, essentially double nest nodes. I saw this post about nesting nodes: Nested TikZ nodes. The solution in that post uses matrices, which, according to: In TikZ, is it possible to nest matrices? is not possible. Also, there is the arrows, not sure where to even start with that, that is probably gonna depend on the implementation of the double nested nodes I guess.

So, I was wondering if it is possible to create that image, or something similar through tikz.

1 Answer 1

4

Welcome to TeX.SX! Don't nest nodes, rather use backgrounds and have a look at the fit library (which has already been mentioned in one of the linked answers):

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit, backgrounds, positioning}

\tikzset{
    every node/.style={
        draw,
        inner sep=10pt,
    }
}

\begin{document}

\begin{tikzpicture}

    \pgfdeclarelayer{background layer}
    \pgfsetlayers{background layer,main}

    \node (one) {Text};
    \node[below=.5cm of one] (two) {Text};
    \node[below=.5cm of two] (three) {Text};

    \node[above=.5cm of one, draw=none] (four) {Text};

    \node[fit={(three) (one)}] (wrap three) {};

    \begin{pgfonlayer}{background layer}
        \node[fit={(wrap three) (four)}, fill=blue!25] (wrap four) {};
    \end{pgfonlayer}

\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.