为定理环境定义双星(**)

为定理环境定义双星(**)

这是未经证明的陈述后的 QED 符号,我真的不确定这是否是解决那里提出的问题的正确方法。但它似乎完美地解决了我遇到的所有情况,所以我会尝试...

定理环境有带编号的常规版本和*不带编号的 'ed 版本。我现在想要另一个**'ed(或类似版本)版本,用于在定理环境周围放置一些东西。

以下是我目前需要做的事情:

\documentclass{amsart}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\begin{document}
\begin{proof}[\unskip\nopunct]
\begin{theorem}
    $e^{2\pi i} = 1$. \qedhere
\end{theorem}
\end{proof}

\begin{proof}[\unskip\nopunct]
\begin{corollary}[{myref}]
    The expression $e^{2\pi i} - 1$ equals $0$. Moreover, there is more text to actually add here. \qedhere
\end{corollary}
\end{proof}
\end{document}

并且我想避免添加\begin{proof}[\unskip\nopunct]\end{proof}我自己,但在两种情况下都使用双星自动获得它。

事实上,交换证明顺序和定理环境,因此提供该版本的解决方案也将受到赞赏!

那是

\begin{myXYZ**}[...]
    ...
\end{myXYZ**}

myXYZ在标题中定义为定理环境)应该简单地转化为

\begin{proof}[\unskip\nopunct]
\begin{myXYZ}[...]
    ...
\end{myXYZ}
\end{proof}

这是可能的吗(或者**用其他东西代替,与使用定理、引理或命题无关)?

答案1

也许这可以解决您的问题。我使用\varnewtheorem与 相同的语法定义了一个命令\newtheorem,但它为我们调用的每个标签创建了四个变体。因此,\varnewtheorem{foo}{Foo}我们创建了四个环境

  • foo(定理,证明如下)
  • foo*(未编号定理,证明如下)
  • foo+(定理,无证明)
  • foo*+(未编号定理,无证明)

该语法照常接受可选参数。

\documentclass{amsbook}
\usepackage{amsthm}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\varnewtheorem}{momo}
 {
  \IfValueTF{#4}
   {\newtheorem{#1}{#3}[#4]}
    {
     \IfValueTF{#2}
      {\newtheorem{#1}[#2]{#3}}
      {\newtheorem{#1}{#3}}
    }
  \newtheorem*{#1*}{#3}
  \newenvironment{#1+}
   {\pushQED{\qed}\begin{#1}}
   {\popQED\end{#1}}
  \newenvironment{#1*+}
   {\pushQED{\qed}\begin{#1*}}
   {\popQED\end{#1*}}
 }
\ExplSyntaxOff

\varnewtheorem{theorem}{Theorem}[chapter]
\varnewtheorem{proposition}[theorem]{proposition}

\begin{document}

\chapter{Test}

\begin{theorem}
A standard theorem statement
\end{theorem}

\begin{theorem*}
A standard unnumbered theorem statement
\end{theorem*}

\begin{theorem+}
A theorem statement without proof
\end{theorem+}

\begin{theorem*+}
An unnumbered theorem statement without proof
\end{theorem*+}


\begin{proposition}
A standard theorem statement
\end{proposition}

\begin{proposition*}
A standard unnumbered theorem statement
\end{proposition*}

\begin{proposition+}
A theorem statement without proof
\end{proposition+}

\begin{proposition*+}
An unnumbered theorem statement without proof
\end{proposition*+}

\end{document}

在此处输入图片描述

答案2

对于每一个\newtheorem{X},你可以调用以下函数\doublestarenv{X}来创建一个X**环境:

在此处输入图片描述

\documentclass{amsart}

\newcommand{\doublestarenv}[1]{%
  \newenvironment{#1**}[1][]
    {\proof[\unskip\nopunct]
     \csname #1\endcsname[##1]}
    {\csname end#1\endcsname
     \endproof}%
}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}

\doublestarenv{theorem}
\doublestarenv{corollary}

\begin{document}

\begin{proof}[\unskip\nopunct]
\begin{theorem}
    $e^{2\pi i} = 1$. \qedhere
\end{theorem}
\end{proof}

\begin{proof}[\unskip\nopunct]
\begin{corollary}[{myref}]
    The expression $e^{2\pi i} - 1$ equals $0$. Moreover, there is more text to actually add here. \qedhere
\end{corollary}
\end{proof}

\begin{theorem**}
    $e^{2\pi i} = 1$. \qedhere
\end{theorem**}

\begin{corollary**}[{myref}]
    The expression $e^{2\pi i} - 1$ equals $0$. Moreover, there is more text to actually add here. \qedhere
\end{corollary**}

\end{document}

您可以通过更新来自动化此过程\newtheorem以自动执行\doublestarenv

\newcommand{\doublestarenv}[1]{%
  \newenvironment{#1**}[1][]
    {\proof[\unskip\nopunct]
     \csname #1\endcsname[##1]}
    {\csname end#1\endcsname
     \endproof}%
}

\usepackage{xparse}

\let\oldnewtheorem\newtheorem
\RenewDocumentCommand{\newtheorem}{ m o m o }{%
  \IfValueTF{#2}
    {\edef\x{\noexpand\oldnewtheorem{#1}[#2]{#3}}}
    {\IfValueTF{#4}
       {\edef\x{\noexpand\oldnewtheorem{#1}{#3}[#4]}}
       {\edef\x{\noexpand\oldnewtheorem{#1}{#3}}}%
    }%
  \x\doublestarenv{#1}%
}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}

答案3

这是@egregtheorem+使用包 的方法create-theorem。以环境theorem为例,它首先theorem通过键创建 和其带星号的变体create starred version,然后使用copy existed分别复制它们的定义并qed添加 QED 符号。

当然,您可以将其命名为theorem+astheorem**theorem*+as theorem***,这是您的选择。

\documentclass{book}

\usepackage{amsthm}
\usepackage{create-theorem}
\CreateTheorem { theorem } { parent counter = chapter, create starred version }
\CreateTheorem { theorem+ } { copy existed = theorem, qed }
\CreateTheorem { theorem*+ } { copy existed = theorem*, qed }
\CreateTheorem { proposition } { shared counter = theorem, create starred version }
\CreateTheorem { proposition+ } { copy existed = proposition, qed }
\CreateTheorem { proposition*+ } { copy existed = proposition*, qed }

\begin{document}

\chapter{Test}

\begin{theorem}
A standard theorem statement
\end{theorem}

\begin{theorem*}
A standard unnumbered theorem statement
\end{theorem*}

\begin{theorem+}
A theorem statement without proof
\end{theorem+}

\begin{theorem*+}
An unnumbered theorem statement without proof
\end{theorem*+}


\begin{proposition}
A standard theorem statement
\end{proposition}

\begin{proposition*}
A standard unnumbered theorem statement
\end{proposition*}

\begin{proposition+}
A theorem statement without proof
\end{proposition+}

\begin{proposition*+}
An unnumbered theorem statement without proof
\end{proposition*+}

\end{document}

在此处输入图片描述

请注意 与create-theorem配合不太好amsbook,因为:

  1. \qedsymbol中的不知amsbook何故显示为\Lambda。这不是什么大问题,但您可以明确地将选项写为qed = \square(前提是\square已定义,例如通过amssymb)。
  2. 最大的问题是内部create-theorem加载cleveref,这与 类不兼容amsbook。解决方法可以在这个答案——然而,定理风格将被破坏。

相关内容