7

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?

6

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

  • @GonzaloMedina Will you make this into an answer with additional comments? :) – Svend Tveskæg Jan 19 '14 at 17:39
  • Is there suppose to be a bigger vertical space between theorem and proof than between proof and proof? – Svend Tveskæg Jan 19 '14 at 18:25
  • Also, I don't get Sætning 1 instead of Theorem 1 as I would expect. – Svend Tveskæg Jan 19 '14 at 18:51
  • @SvendTveskæg Would you ask a new question with your requirements? For the last, just add name=Sætning option in \declaretheorem – karlkoeller Jan 19 '14 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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