6

In my case, I'm only interested in the proof environment, but I believe it applies to any other environment.

I would like to present the proof environment in two different formats, the "Default" format and the "Modified" one.

Since I used the "Modified" format more often, I would like the proof environment to yield the "Modified" format. However, I would like to preserve the "Default" format to be used from time to time, such as changing it to the environment proof2.

In other words:

\begin{proof}
    % "Modified" format
\end{proof}

\begin{proof2}
    % "Default" format
\end{proof2}

As a MWE, say I want the "Modified" format to replace the Proof. to Modified., and the \qedsymbol to a \blacksquare. My attempt would be:

\documentclass[a4paper, 12pt]{article}
\usepackage{amsmath, amsthm}

\newenvironment{proof2}[1][Proof]
  {\begin{proof}[#1]}
  {\end{proof}}
\renewenvironment{proof}[1][Modified]
  {\begin{proof2}[#1]\renewcommand{\qedsymbol}{$\blacksquare$}}
  {\end{proof2}}

\begin{document}

\begin{proof}
    ``Modified'' format.
\end{proof}

\begin{proof2}
    ``Default'' format.
\end{proof2}

\end{document}

which does not work (TeX capacity exceeded), likely due to cyclic definition.

Any help is appreciated.

1 Answer 1

7

Yes, you have a circular definition. Solution: alias the commands to save the original.

\documentclass[a4paper, 12pt]{article}
\usepackage{amsmath, amsthm, amssymb}

% alias the \proof and \endproof commands
\NewCommandCopy{\amsthmproof}{\proof}
\NewCommandCopy{\endamsthmproof}{\endproof}

\renewenvironment{proof}[1][Modified]
  {\renewcommand{\qedsymbol}{$\blacksquare$}\amsthmproof[#1]}
  {\endamsthmproof}
\newenvironment{proof2}
  {\amsthmproof}
  {\endamsthmproof}

\begin{document}

\begin{proof}
    ``Modified'' format.
\end{proof}

\begin{proof2}
    ``Default'' format.
\end{proof2}

\end{document}

enter image description here

Even if it seems to work, don't use " for the closing quotes, but '' (two apostrophes).

Caveat

If you have an older TeX installation with LaTeX prior to 2020-10-01, you can do

% alias the \proof and \endproof commands
\usepackage{letltxmacro}
\LetLtxMacro{\amsthmproof}{\proof}
\LetLtxMacro{\endamsthmproof}{\endproof}
3
  • Hi, I just tried your code, and it returns an undefined control sequence error. I'm not sure but it appears to be \NewCommandCopy that is causing the problem. Jul 20, 2021 at 11:43
  • @ClementYung You seem to have an outdated TeX system. But not all is lost, see the addition to my answer.
    – egreg
    Jul 20, 2021 at 12:38
  • The addition works perfectly. Thank you! Jul 20, 2021 at 13:16

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.