# Defining theorem environment inside a shaded box

How do I define \newtheorem{thm}{Theorem}[section] inside the shaded box \newcommand{\resheading}[1]{{\small \colorbox{lightgray}{\begin{minipage}{0.975\textwidth}{\textbf{#1 \vphantom{p\^{E}}}}\end{minipage}}}}

I know I can just call the resheading command every time I write a theorem, but it'd be more convenient if that process itself were automated.

I don't know exactly if this is what you want, but you can try the following:

Define a new theorem to get the counter

\newtheorem{thm}{Theorem}[section]


Redefine the environment to use the shaded block

\renewenvironment{thm}{
\stepcounter{thm}
\begin{center}
\begin{minipage}{12cm}
{\bfseries Theorem \thethm: }\\
}
{

\begin{thm}