12

I would like to define a new environment with the name oldproof which is basically the proof environment and then make changes to the proof environment. I would still like to be able to access the original proof environment using oldproof. How do I go about doing this?

Peter Grill
  • 223,288
ste_kwr
  • 419
  • What kind of changes would you make to the proof environment? There might be different ways than maintaining two different environments that could give much more flexibility. – egreg Jun 06 '13 at 08:59

1 Answers1

14

An environment <name> will basically translate into two commands: \<name> and \end<name> and the former will deal with eventual argument for the environment. One option then would be to \let the original commands to some other ones; however, since proof has an optional argument, one cannot simply use \let for \proof; additional precautions must be taken and one can use \LetLtxMacro from the letltxmacro package.

\usepackage{amsthm}
\usepackage{letltxmacro}

\LetLtxMacro\oldproof\proof
\let\endoldproof\endproof

A complete example (I introduced two font changes to the original environment, just for illustration purposes):

\documentclass{article}
\usepackage{letltxmacro}
\usepackage{amsthm}

\LetLtxMacro\oldproof\proof
\let\endoldproof\endproof

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


\begin{document}

\begin{proof}
This is a modified proof environment.
\end{proof}

\begin{oldproof}
This is the original proof environment.
\end{oldproof}

\end{document}

enter image description here

Regarding commands with an optional argument and \LetLtxMacro valuable information is provided in egreg's answer to When to use \LetLtxMacro? and, in more detail, in this other answer of his to "Closed" (square) root symbol.

Gonzalo Medina
  • 505,128
  • Thanks. Can you explain why you prefer to use \LetLtxMacro in the first line instead of simply using \let. – ste_kwr Jun 06 '13 at 02:58
  • @set_kwr I was just adding the explanation; the problem is that proof has an optional argument which will be an optional argument for \proof; for commands with optional arguments, \let is not a safe option. – Gonzalo Medina Jun 06 '13 at 03:00