[Tex/LaTex] Drawing LaTeX boxes

boxes

I want to write something like in the attached file.enter image description here

In particular I want the box to be flexible in such a way that it can contain the text — both in the small box and the bigger one.

Any help will be appreciated.

Best Answer

An example with tcolorbox.

\documentclass{article}

\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[1]{%
colback=white,
colbacktitle=white,
coltitle=black,
leftrule=0pt,
rightrule=0pt,
toprule=0.4pt,
bottomrule=0.4pt,
boxsep=0pt,
left=0pt,
right=0pt,
top=10pt,
bottom=10pt,
arc=0pt,
breakable,
enhanced,
attach boxed title to top center={yshift=-2mm},
boxed title style={boxrule=0.4pt,arc=0pt},
title=#1}

\usepackage{lipsum} % just for the example

\begin{document}
\begin{mybox}{A title}
\lipsum[1]
\end{mybox}
\end{document} 

Output

enter image description here