有条件修改 amsart 证明环境

有条件修改 amsart 证明环境

它想修改 amsart 的证明环境,这样如果布尔变量(比如solution在文档的序言中设置为 true)则环境正常工作,否则\begin{proof} content \end{proof}不起作用(即不打印)。有没有办法使用 etoolbox 来做到这一点?

答案1

不是与etoolbox,而是与comment

\documentclass{amsart}

\usepackage{comment}
\makeatletter
\newcommand\pr@@fon{%
  \includecomment{proof}%
  \let\proof\savedproofenv
  \let\proofon\@empty}
\newcommand\proofoff{%
  \ifx\proofon\@empty
    \let\savedproofenv\proof
    \excludecomment{proof}%
    \let\proofon\pr@@fon
  \fi}
\newcommand*\proofon{}%

\proofon

\begin{document}

\begin{proof}
  A proof that is typeset
\end{proof}

\proofoff
\begin{proof}
  A proof that is removed
\end{proof}

\proofon
\begin{proof}
  Another proof that is typeset
\end{proof}

\end{document}

在此处输入图片描述

相关内容