I defined a new environemnt examples for a book I am writing. I would like examples to be with a framed grey box, and use the following construct
%----------------------------------------------------------------------------
% EXAMPLES
%----------------------------------------------------------------------------
\newlistof[chapter]{examples}{exp}{\listexamples}
\newcommand{\bex}[1]{%
\begin{mdframed}[linewidth=2, leftmargin=0, rightmargin=0, backgroundcolor=gray, linecolor=black, splittopskip=\topskip, skipbelow=\baselineskip, skipabove=\baselineskip]
\refstepcounter{examples}
\par\noindent\sqrblt\underline{\textbf{Example \theexamples. #1}}
\addcontentsline{exp}{examples}
{\protect\numberline{\theexamples}#1}\par}
\cftsetindents{examples}{0em}{2em} % for example numbers which are greater than 9
% Solution
\newcommand{\sol}{\begin{center}\underline{{\bf Solution:}}\end{center}}
% End of Example
\newcommand{\eex}{
\noindent \hbox{~~}\hfill \hbox{~~} \sqrblt
\end{mdframed}
}
If I activate the mdframed, I get "not in outer par mode". If I comment the mdframed part, all is well
