How can I improve my code to keep the relative positionning and handle the case above where i want to represent 2 or 3 out of 4 pics ?

I can easily get individuals

But as I reference things relative to other picture position, I obviously get stuck when I want 2 out of 4 next to each other.

```
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\newcommand{\Tikzhedgesymbolic}[1]{
\newif\ifOne
\newif\ifTwo
\newif\ifThree
\newif\ifFour
#1
\tikzset{font=\sffamily,
Risk/.style={fill=brown!30,
draw=brown!70},
Hedge/.style={fill=blue!50,
dotted, fill opacity=0.3},
piclabel/.style 2 args=={text width = 6em,align=center,color=##1,,below =0.25 cm of ##2},
transformer/.style 2 args={draw, cylinder, gray!80, rotate=90, minimum height=##1, minimum width=##2},
Riskpic/.pic={\draw [Risk] (0,0)-- (2,0) -- (2,1) -- (0.90,0.85) -- (1,3) -- (0.05,3) -- cycle;},
Hedge1/.pic={\draw [Hedge] (0,0) -- (1,0) -- (1,3) -- (0,3) -- cycle;},
Hedge2/.pic={\draw [Hedge] (0,0) -- (2,0) -- (2,3) -- (0,3) -- cycle;},
Hedge3/.pic={\draw [Hedge] (0,0) -- (2,0) -- (2,1) -- (1,1) -- (1,3) -- (0,3) -- cycle;}
}
\ifOne
\pic[local bounding box=A] at (0,0) {Riskpic};
\node[piclabel,red,below =0.25 cm of A] {Risque};
\fi
\ifTwo
\pic[local bounding box=B] at (3,0) {Riskpic};
\pic at (3,0) {Hedge1};
\node[piclabel,below =0.25 cm of B] {Sous-hedge vanille};
\fi
\ifThree
\pic[local bounding box=C] at (6,0) {Riskpic};
\pic at (6,0) {Hedge2};
\node[piclabel, below =0.25 cm of C] {Sur-hedge vanille};
\fi
\ifFour
\pic[local bounding box=D] at (9,0) {Riskpic};
\pic at (9,0) {Hedge3};
\node[piclabel, below =0.25 cm of D, blue] {Hedge exotique};
\fi
}
\begin{document}
\tikz \Tikzhedgesymbolic{
\Onetrue
\Twotrue
\Threetrue
\Fourtrue
};
\tikz \Tikzhedgesymbolic{\Onetrue\Fourtrue}; %<- I would like poth picture to be next to each other
\tikz \Tikzhedgesymbolic{\Onetrue};
\tikz \Tikzhedgesymbolic{\Twotrue};
\tikz \Tikzhedgesymbolic{\Threetrue};
\tikz \Tikzhedgesymbolic{\Fourtrue};
\end{document}
```There are different ways to solve this. One is use a `matrix`. I also took the liberty to use `/.is if`. So you need only `\Tikzhedgesymbolic{1,2,3,4}` to get all of them. (It would be possible to extend this to `\Tikzhedgesymbolic{1,...,4}`, but as of now this is not built in.)
```
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\newcommand{\Tikzhedgesymbolic}[1]{
\newif\ifOne
\newif\ifTwo
\newif\ifThree
\newif\ifFour
\Onefalse\Twofalse\Threefalse\Fourfalse
\tikzset{1/.is if=One,2/.is if=Two,3/.is if=Three,4/.is if=Four,#1}
\tikzset{font=\sffamily,
Risk/.style={fill=brown!30,
draw=brown!70},
Hedge/.style={fill=blue!50,
dotted, fill opacity=0.3},
piclabel/.style 2 args=={text width = 6em,align=center,color=##1,,below =0.25 cm of ##2},
transformer/.style 2 args={draw, cylinder, gray!80, rotate=90, minimum height=##1, minimum width=##2},
Riskpic/.pic={\draw [Risk] (0,0)-- (2,0) -- (2,1) -- (0.90,0.85) -- (1,3) -- (0.05,3) -- cycle;},
Hedge1/.pic={\draw [Hedge] (0,0) -- (1,0) -- (1,3) -- (0,3) -- cycle;},
Hedge2/.pic={\draw [Hedge] (0,0) -- (2,0) -- (2,3) -- (0,3) -- cycle;},
Hedge3/.pic={\draw [Hedge] (0,0) -- (2,0) -- (2,1) -- (1,1) -- (1,3) -- (0,3) -- cycle;}
}
\matrix[ampersand replacement=\&,column sep=2em]{
\ifOne
\pic[local bounding box=A] {Riskpic};
\node[piclabel,red,below =0.25 cm of A] {Risque}; \&
\fi
\ifTwo
\pic[local bounding box=B] {Riskpic};
\pic {Hedge1};
\node[piclabel,below =0.25 cm of B] {Sous-hedge vanille}; \&
\fi
\ifThree
\pic[local bounding box=C] {Riskpic};
\pic {Hedge2};
\node[piclabel, below =0.25 cm of C] {Sur-hedge vanille};\&
\fi
\ifFour
\pic[local bounding box=D] {Riskpic};
\pic {Hedge3};
\node[piclabel, below =0.25 cm of D, blue] {Hedge exotique};
\fi
\\};
}
\begin{document}
\tikz \Tikzhedgesymbolic{1,2,3,4};
\tikz \Tikzhedgesymbolic{1,4}; %<- I would like poth picture to be next to each other
\tikz \Tikzhedgesymbolic{1};
\tikz \Tikzhedgesymbolic{2};
\tikz \Tikzhedgesymbolic{3};
\tikz \Tikzhedgesymbolic{4};
\end{document}
```
