# Enclosing a float into a shadowed box

I have created a float enivoirment as shown below

\floatstyle{boxed}
\newfloat{example}{thp}{lop}[section]
\floatname{example}{Example}


I would like to enclose the example in the a shadowbox, including its caption and numbering and also provide a coloured background. Example is provided below.

----------------------------------------------
| Example 2.3: How to define an attribute    |
|                                            |
| def ..etc                                  |
|                                            |
----------------------------------------------


Any ideas

This is how you can use the solution that Wener points out. Also, you will need to use and install the new version of the mdframed as explained here.

\documentclass{article}
\usepackage{float}
\usepackage[framemethod=tikz]{mdframed}

% Styles

\makeatletter
% General command that defines the mdframed
\def\@fs@pre{\begin{mdframed}[style=#1]}%
\def\@fs@mid{}%
\def\@fs@post{\end{mdframed}}\let\@fs@iftopcapt\iffalse}
% Link the style with the frame, giving it a name
\makeatother

\pagestyle{empty}
\begin{document}

\floatstyle{yellowFloat}
\restylefloat{figure}% bind the style to the figure
\begin{figure}[h]
\centering
\rule{100pt}{150pt}
\caption{Some caption}
\end{figure}

\floatstyle{blueFloat}
\restylefloat{figure}% bind the style to the figure
\begin{figure}[h]
\centering
\rule{100pt}{150pt}
\caption{Another caption}
\end{figure}
\end{document}


• Perfect! Is it possible to have different styles for different floats. In my book, i have floats of different type, 'Examples', 'Logs', 'code snippets', etc Feb 6, 2012 at 12:17
• Yes you can, see my update.