# Create example frame

How to create this type of example box? Thank you!

• with tcolorbox or mdframed. Mar 8, 2017 at 17:58
• I would say: Typical tcolorbox environment...
– user31729
Mar 8, 2017 at 18:03

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}


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:

• With skins library, the enhanced and sharp corners, it would even look more like the example in the O.P. screen shot
– user31729
Mar 8, 2017 at 18:38
• @ChristianHupfer I never used sharp corners, thanks for the tip. I don't think OP needs something that looks just like the example because the question was how to create this type of boxes. Feedback from OP might help here. Mar 8, 2017 at 18:40
• @ChristianHupfer I've added the changes you suggested in a second code snippet. Mar 8, 2017 at 18:57
• @Duy if this answer satisfies your needs you should accept it. Mar 9, 2017 at 19:39
• @skillmon I use \documentclass{dmathesis} so it can not run the code. It appears "Can be only used in preamble". Could you help me fix it?
– Duy
Apr 12, 2017 at 6:31

Another possibility would be to use a table to do something like this...

Code:

\documentclass{amsart}
\usepackage{lipsum}
\usepackage[table]{xcolor}
\usepackage{color}
\usepackage{array}
\begin{document}

\begin{table}[htp]
\begin{tabular}{|cp{5in}c|}
\hline
\cellcolor{black!100}&\multicolumn{1}{p{5in}}{\cellcolor{black!100}{\color{white}\Large{Some Title Here...}}}&\cellcolor{black!100}\\\hline
&\vskip .01in \lipsum[1]&
\end{tabular}
\end{table}
\end{document}


Yields:

• Why do you define more columns than necessary? If you just want extra space you can get that using: \begin{tabular}{|@{\hspace{1em}}p{5in}@{\hspace{1em}}|}` Mar 8, 2017 at 18:32
• @Skillmon You are quite right, except that in this case doing that results in the top cell having white strips on both sides. Where it should be black.
– Dan
Mar 8, 2017 at 18:33
• I just realised that. There might be a hacky way to get those, though :) Mar 8, 2017 at 18:45