在 thmtools 中定义证明环境

在 thmtools 中定义证明环境

我在用着thm工具看起来很花哨的数学环境。但我不知道如何重新定义证明环境。我在其文档中找不到此类主题。

这是我的 LaTeX 代码片段。

\documentclass{article}

\usepackage{color}
\definecolor{section_color}{rgb}{0.35,0.0,0}
\definecolor{MyGray}{rgb}{0.96,0.97,0.98}

\usepackage{amsthm,thmtools}

% defining common style
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\color{section_color}\sffamily\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
qed=,
]{mystyle}

% defining theorem environment
\declaretheorem[
style=mystyle,
shaded={bgcolor=MyGray,padding=2mm,textwidth=0.98\textwidth}
]{theorem}

% defining claim environment
\declaretheorem[
sibling=theorem,
style=mystyle,
shaded={bgcolor=MyGray,padding=2mm,textwidth=0.98\textwidth}
]{claim}

\begin{document}
%title{Thmtools Example}

\begin{theorem}[Euler's identity]
$e^{i\pi} + 1 = 0$
\end{theorem}

\begin{proof}
Use Euler's formula $e^{ix} = \cos x + i\sin x$.
\end{proof}

\begin{proof}[Proof of Fermat's Last Theorem]
Ask Andrew Wiles.
\end{proof}

\end{document}

在此处输入图片描述

我想要的证明环境是:

  1. 它与其他环境具有相同的风格:相同的字体、相同的粗体和相同的文本颜色
  2. 但它没有阴影背景。
  3. 它可以处理一个参数,以便可以改变标题“证明”,如第二个证明示例所示。

如何使用 thmtools 重新定义证明环境?

答案1

我发现最好的方法是重新定义环境proof,即在序言中添加以下几行:

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \color{section_color}\sffamily\bfseries
    #1\@addpunct{.}]\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse
}
\makeatother

平均能量损失

\documentclass{article}

\usepackage{color}
\definecolor{section_color}{rgb}{0.35,0.0,0}
\definecolor{MyGray}{rgb}{0.96,0.97,0.98}

\usepackage{amsthm,thmtools}

% defining common style
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\color{section_color}\sffamily\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
qed=,
]{mystyle}

% defining theorem environment
\declaretheorem[
style=mystyle,
shaded={bgcolor=MyGray,padding=2mm,textwidth=0.98\textwidth}
]{theorem}

% defining claim environment
\declaretheorem[
sibling=theorem,
style=mystyle,
shaded={bgcolor=MyGray,padding=2mm,textwidth=0.98\textwidth}
]{claim}

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \color{section_color}\sffamily\bfseries
    #1\@addpunct{.}]\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse
}
\makeatother

\begin{document}
%title{Thmtools Example}

\begin{theorem}[Euler's identity]
$e^{i\pi} + 1 = 0$
\end{theorem}

\begin{proof}
Use Euler's formula $e^{ix} = \cos x + i\sin x$.
\end{proof}

\begin{proof}[Proof of Fermat's Last Theorem]
Ask Andrew Wiles.
\end{proof}

\end{document} 

输出:

在此处输入图片描述

如果定理和声明使用的边距中的额外间距也应用于证明,则可以将上述重新定义更改为(感谢 Gonzalo Medina 的建议)

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \list{}{\leftmargin=1.25mm\itemindent=20pt\linewidth=0.975\textwidth%
  \item[\hskip\labelsep
        \color{section_color}\sffamily\bfseries
   #1\@addpunct{.}]\ignorespaces}
}{%
  \popQED\endlist\@endpefalse
}
\makeatother

你将获得

在此处输入图片描述

相关内容