如何从框架包中创建 snugshade 框的变体,以便将我的定义环境包装在蓝色框中?

如何从框架包中创建 snugshade 框的变体,以便将我的定义环境包装在蓝色框中?

我已经在使用 snugshade 将我的定理环境包装在灰色框中,但我希望有另一个像 snugshade 一样的边界框将我的定义包装在蓝色框中。

这是我的代码:

    \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}

答案1

我建议你使用包裹mdframed相反,因为这允许分页符和更多自定义。

但是,您可以简单地重新定义shadecolor。已经定义了一个自定义Snugshade环境,允许您指定颜色

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

如果未指定,则默认为gray您使用的:

在此处输入图片描述

代码:

\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}

相关内容