# How to fill in node names and node values in pic environment with predefined variables?

I got a graphic with many nodes (~40). I want to add the same type of "sub-nodes" to each of them (view image, one node with a label that contains a name and another node with a label that contains a value). This can be reasonable easily done by combining the \foreach and the pic or pics environment.

However I did not manage to give the pic environment the arguments I wanted to give it. What I wanted to give were the variables I defined e.g. {a-label}{a-label}, {a-value}{3} etc. so that I could update the node labels, I was only able to update the options "e.g. color red".

What is a possible way to do it?

Since the final layout (both in relations and node configuration) isn't clear yet, I'd rather not have many specific written out lines, but a general "function" in which I iterate over with my "node list" that fills in the required "variables" from my predefined values.

• If you define your pic by pics/nodegroup/.style args={#1/#2}{...} then you can use it like this pic{nodegroup={My Lable/3}}. You can check for example this question. – Kpym Apr 29 '18 at 14:47
• It would have been great if you could add a complete example with such a pic, perhaps without variables, just hardcoded nodes. Easier for those trying to help if we do not have to start from scratch. Did the comment above help, by the way? – Torbjørn T. May 13 '18 at 19:51

One way is to go as @Kpym suggests, another way is to use the fit library to fit the (sub-)nodes into bigger schemes.

\documentclass[tikz]{standalone}
\usetikzlibrary{fit,arrows.meta,positioning}
\tikzset{bigbox/.style={draw,thick,minimum width=5cm,minimum
height=5cm,align=center},
smallbox/.style={draw,thick,minimum width=4.5cm,align=center}}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
\node[bigbox,label={[yshift=7mm]below:{"some node A"}}] (A) {};
\node[bigbox,below=of A,label={[yshift=7mm]below:{"some node B"}}] (B) {};
\node[smallbox,right=of A.38] (n-label){n-label: "MyLabel"};
\coordinate[right=2mm of n-label](xr);
\coordinate[left=2mm of n-label](xl);
\node[smallbox,below=3mm of n-label] (n-value){n-value: [some value]};
\node[draw,thick,fit=(xl|- A.south) (xr|- A.north),inner sep=-0.5\pgflinewidth] (Fit) {};
\draw[shorten >=2pt,shorten <=2pt,-Triangle,line width=1mm] (A) -- (Fit);
\end{tikzpicture}
\end{document}