[Tex/LaTex] Define proof environment in thmtools

theoremsthmtools

I'm using thmtools for fancy-looking math environments. But I don't know how to redefine proof environment. I cannot find such topics in its documentation.

This is my LaTeX code snippet.

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

enter image description here

What I want for the proof environment is:

  1. It has the same style as other environments: same font, same boldface, and same text color
  2. But it has no shaded background.
  3. It can handle an argument so that the title 'Proof' can be changed, as shown in the second proof example.

How can I redefine proof environment using thmtools?

Best Answer

The best way I've found is to redefine the proof environment, that is, add the following lines in your preamble:

\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

MWE

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

Output:

enter image description here

If the additional extra spacing in the margins used for theorems and claims should also be used for proofs, you can change the above redefinition to (thanks to Gonzalo Medina for suggesting it)

\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

and you will obtain

enter image description here

Related Question