[Tex/LaTex] How to create Multilevel Colored Boxes using tcolorbox/any other package

boxescolorformattingframedtcolorbox

tcolorbox Manual provides the following example:

enter image description here

Can anybody please suggest me how to create exactly this type of box – The no. of rows to add must be flexible(It seems that tcolorbox has no option other than top & bottom):

enter image description here

Best Answer

And here's one possibility using mdframed:

\documentclass{article}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}

\definecolor{mybrown}{RGB}{128,64,0}

\mdfdefinestyle{mystyle}{%
linecolor=mybrown,outerlinewidth=1pt,%
frametitlerule=true,frametitlefont=\sffamily\bfseries\color{white},%
frametitlerulewidth=1pt,frametitlerulecolor=mybrown,%
frametitlebackgroundcolor=mybrown,
backgroundcolor=mybrown!05,
innertopmargin=\topskip,
roundcorner=5pt
}
\mdtheorem[style=mystyle]{example}{Example}

\gdef\Sepline{%
  \par\noindent\makebox[\linewidth][l]{%
  \hspace*{-\mdflength{innerleftmargin}}%
   \tikz\draw[thick,dashed,gray!60] (0,0) --%
        (\textwidth+\the\mdflength{innerleftmargin}+\the\mdflength{innerrightmargin},0);
  }\par\nobreak}


\begin{document}

\begin{example}[The Title]
The contents of the first part.
\Sepline
\noindent The contents of the second part.
\Sepline
\noindent The contents of the third part.
\Sepline
\noindent The contents of the fourth part.
\end{example}

\end{document}

enter image description here

Here's now a modification not using a theorem-like structure, but a simple environment with a mandatory argument to provide a title:

\documentclass{article}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}

\definecolor{mybrown}{RGB}{128,64,0}

\mdfdefinestyle{mystyle}{%
linecolor=mybrown,outerlinewidth=1pt,%
frametitlerule=true,frametitlefont=\sffamily\bfseries\color{white},%
frametitlerulewidth=1pt,frametitlerulecolor=mybrown,%
frametitlebackgroundcolor=mybrown,
backgroundcolor=mybrown!05,
innertopmargin=\topskip,
roundcorner=5pt
}
\newmdenv[style=mystyle]{exa}
\newenvironment{example}[1]
  {\begin{exa}[frametitle=#1]}
  {\end{exa}}

\gdef\Sepline{%
  \par\noindent\makebox[\linewidth][l]{%
  \hspace*{-\mdflength{innerleftmargin}}%
   \tikz\draw[thick,dashed,gray!60] (0,0) --%
        (\textwidth+\the\mdflength{innerleftmargin}+\the\mdflength{innerrightmargin},0);
  }\par\nobreak}

\begin{document}

\begin{example}{The Title}
The contents of the first part.
\Sepline
\noindent The contents of the second part.
\Sepline
\noindent The contents of the third part.
\Sepline
\noindent The contents of the fourth part.
\end{example}

\end{document}

enter image description here

Related Question