[Tex/LaTex] Highlight environment by setting a gray background color

backgroundscolorhighlighting

The title explains everything. I have a theorem with ntheorem and want to highlight it with a gray background color. What would be the easiest way to achieve this?

Best Answer

Just use mdframed package. Here is an example from the document with a little modification:

\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}
\newtheorem{mdtheorem}{Theorem}
\newenvironment{theorem}%
  {\begin{mdframed}[backgroundcolor=lightgray]\begin{mdtheorem}}%
  {\end{mdtheorem}\end{mdframed}}

\begin{document}

\begin{theorem}
test
\end{theorem}

\end{document}