[Tex/LaTex] Create example frame

boxesexamples

enter image description here
How to create this type of example box? Thank you!

Best Answer

A possibility is the usage of tcolorbox like this:

\documentclass[11pt]{standalone}

\usepackage{tcolorbox}

\newcommand{\myexample}[2]{
    \begin{tcolorbox}[colback=black!5!white,colframe=black,title={Example: #1}]
        #2
    \end{tcolorbox}
}

\begin{document}
\myexample{test}{This is just a test}
\end{document}

The result of above code

To get something which looks more like the example image provided (thanks to Christian Hupfer) you could use:

\documentclass[11pt]{standalone}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\newcommand{\myexample}[2]{
    \begin{tcolorbox}[enhanced,colback=black!5!white,colframe=black,sharp corners,title={Example: #1}]
        #2
    \end{tcolorbox}
}

\begin{document}
\myexample{test}{This is just a test}
\end{document}

Which results in:

result of second code snippet

Related Question