2

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

  • 1
    Could you provide some sense of what you've tried? Something the community can work with as a foundation? – Werner Oct 25 '15 at 17:07
5

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.

  • Shouldn't you have \refstepcounter, so that cross references work? – Torbjørn T. Oct 25 '15 at 19:23
  • @TorbjørnT. - Thank you for the suggestion, I updated my answer accordingly. – AboAmmar Oct 25 '15 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.