[Tex/LaTex] How to create a nice box

tablestcolorbox

I want to create a nice box like the one in the image below. I tried to use this link: title style in tcolorbox

enter image description here

Best Answer

Some thing like this:

enter image description here

\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\begin{document}
\newcounter{mycounter}

\tcbset{examplebox/.style={enhanced,colback=white,colframe=green!65!black,
enlarge top by=10mm,
overlay={%
\path[fill=blue!65,line width=.4mm] (frame.north west)--++(17mm,0)coordinate(n2)--++(0,8mm)--++(-20mm,0) arc (-90:90:-4mm)--cycle;
\node at ([shift={(5mm,4mm)}]frame.north west){\color{white}{\textbf{\sffamily EXAMPLE}}};
\path[fill=green!65!blue] ([xshift=.4mm]n2)--++(0,8mm)--++(7mm,0)--++(0,-8mm)--cycle;
\node at ([shift={(4mm,4mm)}]n2){\color{white}{\textbf{\sffamily \themycounter}}};
\node at ([shift={(18mm,4mm)}]n2){\itshape\textbf{\sffamily Solution}};
}}}

Some text before ...
\begin{tcolorbox}[examplebox,step=mycounter,label=one]
This is a \textbf{tcolorbox}.\par
a lot of text here ... This is Example \ref{one}
\end{tcolorbox}
Some text after ...

Some text before ...
\begin{tcolorbox}[examplebox,step=mycounter,label=two]
This is a \textbf{tcolorbox}.\par
a lot of text here ... This is Example \ref{two}
\end{tcolorbox}
Some text after ...

\end{document}

You can use the feature-rich tcolorbox package with your own style. You should add the \tcbuselibrary{skins} library to be able to add custom TikZ overlays using the \tcbset{examplebox/.style={...}}. You will also need a \newcounter to automatically number your example solutions. This is achieved by:

\newcounter{mycounter}

and in the options for tcolorbox, add step=mycounter,label=<...> for cross referencing. Therefore, In your style definition, put the \themycounter command in place of the example number.