[Tex/LaTex] How to create a variant of the snugshade box from the framed package to wrap the definition environments in a blue box

formattingframed

I'm already using snugshade to wrap my theorem environments in a grey box, but I'd like to have another bounding box just like snugshade to wrap my definitions in a blue box instead.

Here is my code:

    \documentclass[english,nohyper]{tufte-handout}
    \usepackage{amsthm}
    \usepackage{amsmath}
    \usepackage{amssymb}

    \makeatletter
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
    \usepackage{enumitem}       % customizable list environments
      \theoremstyle{definition}
      \newtheorem{defn}{\protect\definitionname}
      \theoremstyle{remark}
      \newtheorem*{rem*}{\protect\remarkname}
      \theoremstyle{definition}
      \newtheorem*{example*}{\protect\examplename}
    \theoremstyle{plain}
    \newtheorem{thm}{\protect\theoremname}

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.

    \usepackage[dvipsnames]{xcolor}
    \usepackage{framed}
    \definecolor{shadecolor}{RGB}{236,236,236} %defines color of snugshade box
    \setcounter{secnumdepth}{2}
    \setcounter{tocdepth}{2}
    \renewcommand{\sectionmark}[1]{%
      \markboth{}{\thesection.\ #1}}

    \makeatother

    \usepackage{babel}
      \providecommand{\definitionname}{Definition}
      \providecommand{\examplename}{Example}
      \providecommand{\remarkname}{Remark}
    \providecommand{\theoremname}{Theorem}

    \begin{document}
    \begin{snugshade}
    \begin{defn}
    Let $A\subseteq\mathbb{R}$ and let $f:A\rightarrow\mathbb{R}$, we
    say that $f$ is \textbf{continuous }on $A$, if given $\varepsilon>0$
    and $u\in A$, there exists a $\delta_{\varepsilon,u}>0$, perhaps
    depending on $u$, such that 
    \[
    \left|f\left(x\right)-f\left(u\right)\right|<\varepsilon\quad\text{whenever }x\in A\text{ and }\left|x-u\right|<\delta_{\varepsilon,u}
    \]
     Essentially to say that a function $f$ is continuous on $A$ is
    to say that $f$ is continuous at every point $u\in A$.\end{defn}
    \end{snugshade}

    \begin{snugshade}
    \begin{thm}
    More text\end{thm}
    \end{snugshade}
    \end{document}

Best Answer

I would recommend you use the mdframed package instead, as that allows for page breaks and much more customization.

However, you can simply redefine shadecolor. have defined a custom Snugshade environment that allows you to specify the color

\newenvironment{Snugshade}[1][236,236,236]{
    \definecolor{shadecolor}{RGB}{#1}%
    \begin{snugshade}%
}{%
    \end{snugshade}%
}

If not specified, it defaults to the gray you were using:

enter image description here

Code:

\documentclass[english,nohyper]{tufte-handout}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{enumitem}       % customizable list environments
  \theoremstyle{definition}
  \newtheorem{defn}{\protect\definitionname}
  \theoremstyle{remark}
  \newtheorem*{rem*}{\protect\remarkname}
  \theoremstyle{definition}
  \newtheorem*{example*}{\protect\examplename}
\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.

\usepackage[dvipsnames]{xcolor}
\usepackage{framed}
\definecolor{shadecolor}{RGB}{236,236,236} %defines color of snugshade box
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\renewcommand{\sectionmark}[1]{%
  \markboth{}{\thesection.\ #1}}

\makeatother

\usepackage{babel}
  \providecommand{\definitionname}{Definition}
  \providecommand{\examplename}{Example}
  \providecommand{\remarkname}{Remark}
\providecommand{\theoremname}{Theorem}


\newenvironment{Snugshade}[1][236,236,236]{
  \definecolor{shadecolor}{RGB}{#1}%
  \begin{snugshade}%
}{%
    \end{snugshade}%
}

\begin{document}
\begin{snugshade}
\begin{defn}
Let $A\subseteq\mathbb{R}$ and let $f:A\rightarrow\mathbb{R}$, we
say that $f$ is \textbf{continuous }on $A$, if given $\varepsilon>0$
and $u\in A$, there exists a $\delta_{\varepsilon,u}>0$, perhaps
depending on $u$, such that 
\[
\left|f\left(x\right)-f\left(u\right)\right|<\varepsilon\quad\text{whenever }x\in A\text{ and }\left|x-u\right|<\delta_{\varepsilon,u}
\]
 Essentially to say that a function $f$ is continuous on $A$ is
to say that $f$ is continuous at every point $u\in A$.\end{defn}
\end{snugshade}

\begin{snugshade}
\begin{thm}
More text\end{thm}
\end{snugshade}

\begin{Snugshade}[106,176,226]
\begin{thm}
    More text inside default Snugshade with option 106,176,226.
\end{thm}
\end{Snugshade}

\begin{Snugshade}
\begin{thm}
More text inside default Snugshade
\end{thm}
\end{Snugshade}
\end{document}