使用 ntheorem、thmmarks 和 no amsthm,正确定义证明环境

使用 ntheorem、thmmarks 和 no amsthm,正确定义证明环境

我使用ntheoremthmmarks选项但不带amsthm选项(原因我就不多说了)。我想proof按照 来定义环境amsthm。具体来说,我想要:

  • 为了能够使用 proofSymbol 命令来影响所有证明,如这个答案
  • 能够指定,默认情况下,证明将没有 QED 符号。
  • 对于证明符号,当它出现时,默认出现在行尾(即 之后\hfil)。

我所做的是“提取”以下定义ntheorem.sty

\newcommand{\openbox}{\leavevmode
  \hbox to.77778em{%
  \hfil\vrule
  \vbox to.675em{\hrule width.6em\vfil\hrule}%
  \vrule\hfil}}
\gdef\proofSymbol{\openbox}
\newcommand{\proofname}{Proof}
\newenvironment{proof}[1][\proofname]{
  \th@nonumberplain
  \def\theorem@headerfont{\itshape}%
  \normalfont
  \theoremsymbol{\ensuremath{_\blacksquare}}
  \@thm{proof}{proof}{#1}}%
  {\@endtheorem}

并添加计数器定义。以下是工作示例中的结果:

\documentclass{article}
\usepackage[thmmarks]{ntheorem}
\usepackage{amssymb}
\usepackage{lipsum}

\makeatletter
\newcommand{\openbox}{\leavevmode
  \hbox to.77778em{%
  \hfil\vrule
  \vbox to.675em{\hrule width.6em\vfil\hrule}%
  \vrule\hfil}}
\gdef\proofSymbol{\openbox}
\newcommand{\proofname}{Proof}
\newcounter{proof}\newcounter{currproofctr}\newcounter{endproofctr}
\newenvironment{proof}[1][\proofname]{
  \th@nonumberplain
  \def\theorem@headerfont{\itshape}%
  \normalfont
  \theoremsymbol{\ensuremath{_\blacksquare}}
  \@thm{proof}{proof}{#1}}%
  {\@endtheorem}
\makeatother

\renewcommand\proofSymbol{\ensuremath{\blacksquare}}

\begin{document}
\begin{proof}
Without \verb|\qed| in this one.
\end{proof}
\begin{proof}
With \verb|\qed| in this one. \qed
\end{proof}
\end{document}

编辑:从 MWE 中删除了 \lipsum ) 发生的情况是,当我不指定 时,我得到一个黑色方块\qed,但当我指定 时,没有黑色方块。所以,

  • 我现在怎么去\qed上班?
  • 为了避免现在默认使用符号,我只需设置\theoremsymbol{\relax},对吗?
  • 我可以克服“\par结束前没有”的限制吗?

答案1

以下是详细操作方法:我定义了两个不同的环境,proof(带有 qed 符号)和proof-wo不带有 qed 符号。

但是,请注意,仅定义一个证明环境(默认带有 qed 符号)就足够了,\NoEndMark如果您不想要这个符号,则添加。

另外,我不明白对证明进行编号的意义。不过,如果您真的想这样做,只需将定理样式更改为,plain并替换\newtheorem{proof-wo}{Proof}为,\newtheorem{proof-wo}[proof]{Proof}如果您希望两个环境都只有一个计数器。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage[amsmath, thmmarks]{ntheorem}
\usepackage{amssymb}
\usepackage{lipsum}
 \theoremstyle{nonumberplain}
 \theoremheaderfont{\itshape}
 \theorembodyfont{\normalfont}
 \theoremseparator{.\,—}
 \theoremsymbol{}
 \newtheorem{proof-wo}{Proof}
 \theoremsymbol{\ensuremath{\color{lightgray}\blacksquare}}
 \newtheorem{proof}{Proof}

\begin{document}

\begin{proof-wo}
Without \verb|\qed| Nam dui ligula, fringilla a, euismod sodales, sollicitudin
vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis
vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat
ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hen-
drerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum
sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellen-
tesque cursus luctus mauris.
\end{proof-wo}

%
\begin{proof}
With \verb|\qed| Nam dui ligula, fringilla a, euismod sodales, sollicitudin
vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis
vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat
ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hen-
drerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum
sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellen-
tesque cursus luctus mauris.
\end{proof}
%
\begin{proof}\NoEndMark
Without \verb|\qed| Nam dui ligula, fringilla a, euismod sodales, sollicitudin
vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis
vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat
ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hen-
drerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum
sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellen-
tesque cursus luctus mauris.
\end{proof}

\end{document} 

在此处输入图片描述

答案2

评论太长了

制作环境的标准方法ntheorem proof类似于(未经测试,匆忙)

\usepackage[amsmath,thmmarks]{ntheorem}
\theoremstyle{nonumberplain}
\theoremheaderfont{\itshape}
\theorembodyfont{\normalfont}
\theoresymbol{\ensuremath\square}
\newtheorem{proof}{Proof}

我不明白你为什么要使用所有这些代码。

然后我还会创建一个有空的变体\theoremsymbol并称之为proof*

请记住,ntheoremamsthm是非常不同的野兽,前者不支持\qed

相关内容