# How do I make sections with different sizes in a rectangle/box?

I was inspired by how HAL is shown in this picture and would like to make something that is more or less the same in latex.

This is my current code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfgantt}
\usepackage{float}

\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{darkgray}{rgb}{0.66,0.66,0.66}
\definecolor{black}{rgb}{0,0,0}
\definecolor{white}{rgb}{1, 1, 1}

\tikzset{block/.style={rectangle, draw, fill=gray!50,
text width=10em, text centered, rounded corners=0pt, minimum height=0em}}

\title{boxes}
\date{February 2020}

\begin{document}

\maketitle

\begin{figure}[H]
\centering
\begin{tikzpicture}
\node[block, minimum height=2cm, fill=darkgray!150, below=of task, yshift=1cm] (executive) {Executive};
\node[block, minimum height=3cm, yshift=1cm, below=of executive] (driver) {Drivers};
\node[block, minimum height=1cm, below of=driver, xshift=0.53cm, text width=7em] (hal) {Hardware abstraction layer};
\node[block, minimum height=2cm, below=of driver, yshift=1cm](hardware) {Hardware};

\end{tikzpicture}

\caption{\label{fig:Fig1_ecosystem}HALs place in the hierarchy of the executionpath}

\end{figure}

\end{document}


This is the output:

• Can you show us what you've tried? Feb 27 '20 at 17:38
• This can be done with a simple table using \rowcolor and \cellcolor. There a lot of questions using these commands. Search a bit.
– Fran
Feb 27 '20 at 19:19
• @Werner I'm very new to latex and was kinda assuming I was doing it all wrong. But I have now added my code. Feb 27 '20 at 21:18
• @Fran Didn't see your comment before now, but as you see in the edit I found a way, kinda. I was searching for the wrong things(boxes within boxes and whatnot) which were why I couldn't find anything, thus leading to my post. Would you suggest a more elegant solution? Feb 27 '20 at 21:23
• @brynagutyes I added an answer. Mot sure if it is more elegant, but indeed is simpler.
– Fran
Feb 27 '20 at 22:07

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array}
\begin{document}
\renewcommand\arraystretch{2}
\begin{tabular}{m{2cm}p{2cm}}
\rowcolor{gray!20}\multicolumn{2}{c}{bla bla bla} \\
\rowcolor{gray}\multicolumn{2}{c}{bla bla bla} \\
\rowcolor{gray!20}\multicolumn{2}{c}{bla bla bla} \\
\rowcolor{gray!20}            & \cellcolor{gray!40}   bla bla bla bla bla bla     \\
\rowcolor{black}\multicolumn{2}{c}{\color{white} bla bla bla} \\
\end{tabular}
\end{document}

• Thank you, this was much more elegant and very appreciated :) Feb 27 '20 at 22:11