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?
- 223,288
- 419
1 Answers
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}

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.
- 505,128
-
Thanks. Can you explain why you prefer to use
\LetLtxMacroin 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
proofhas an optional argument which will be an optional argument for\proof; for commands with optional arguments,\letis not a safe option. – Gonzalo Medina Jun 06 '13 at 03:00
proofenvironment? There might be different ways than maintaining two different environments that could give much more flexibility. – egreg Jun 06 '13 at 08:59