I need nested boxes, as they are shown in this question, but colored ones.
I tried both solutions. Using shapes.multipart
I totally failed when tried to generate the nodeparts by a foreach
command. If I use multiple \tikz
parts in one nodepart, I can use foreach
, but I am unable to put them in one column (tried matrix and failed).
Trying drs
with xcolor
I almost got a correct result, but when I write this:
\documentclass{article}
\usepackage{drs}
\usepackage{xcolor}
\begin{document}
\colorbox{green}
{
\drs{box label}
{
drs box text
}
}
\end{document}
some margin around the drs
generated box is colored as well.
What I basically need is to draw a colored box with some label. Then, by a foreach
loop, to generate several colored boxes inside it. It is perfectly possible to have them in one column.
Following advice from egreg I wrote this:
\documentclass{article}
\newcommand{\zcolorbox}[2]{{\setlength{\fboxsep}{0pt}\colorbox{#1}{#2}}}
\newcommand{\nestedbox}[3]{\zcolorbox{#1}{\drs{#2}{#3}}}
\usepackage{drs}
\usepackage{xcolor}
\begin{document}
\nestedbox{green}{box label}{\nestedbox{yellow}{inner box label}{inner box text}}
\end{document}
and got this:
How can I get rid of the yellow color there, but not of the space?
Best Answer
I open a small discuss.
Here an approach using LaTeX3 in combination of some features defined in the kernel LaTeX2e.
The input of your colorbox is as follow:
where the
inner box
is a comma separated list.The available options are:
outer-color
sets the background color of the whole boxinner-color
sets the background of the inner boxbgcolor
setsinner-color
andouter-color
line-color
sets the color of the frame`margin
adds extra space to the widest wordalignment
choose the alignment of the boxes. Available areleft
,right
andcenter
header-font
sets the font of the headerlabel-font
sets the font of the inner boxesHere the complete code.
In the final pdf I have no lines between the inner boxes.