Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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}
share|improve this answer
    
This is precisely what I needed. Thanks. I'll have to tinker with mdframed, but framed suits my needs for now. –  Black Milk Nov 9 '12 at 2:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.