\newcounter{sidebarcounter}
\definecolor{sidebarcolor}{gray}{.90}
\newsavebox{\savesidebar}
\newenvironment{sidebar}[2]{\begin{lrbox}{\savesidebar}\refstepcounter{sidebarcounter}\begin{minipage}[t]{#1}
\begin{center}\begin{minipage}[t]{0.9#1}
{\large \rule[2ex]{0pt}{0pt} \textbf{Sidebar \thesidebarcounter : #2}\hfill\\\rule[1ex]{\textwidth}{1pt}\\}\setlength{\parindent}{17pt}}
{\end{minipage}\vspace{6pt}\end{center}\end{minipage}\end{lrbox}\begin{figure}[!tbh]\fcolorbox{black}{sidebarcolor}{\usebox{\savesidebar}}\end{figure}}

\newenvironment{sidebar*}[2]{\begin{lrbox}{\savesidebar}\begin{minipage}[t]{#1}%
{\textbf{#2}\hfill\\\rule[1ex]{\textwidth}{1pt}\\}\setlength{\parindent}{17pt}}
{\end{minipage}\end{lrbox}\fcolorbox{black}{sidebarcolor}{\usebox{\savesidebar}}}

\newcommand{\BeginSidebar}[2]{\begin{sidebar}{#1}{#2}\small}
\newcommand{\EndSidebar}{\end{sidebar}}
