定理末尾的 QED(定义式)环境

定理末尾的 QED(定义式)环境

如果这是重复的,请见谅。

\documentclass[12pt]{extbook}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{etoolbox}
\theoremstyle{definition}
\newtheorem{example}{Example}[section]
\AtEndEnvironment{example}{\qed}%
%example
\begin{document}
\begin{example}
For example, if $E$ is the set of even numbers,
\begin{equation*}
\{x \in E: x = 2\}
\end{equation*}
is the set of all even numbers $x$ such that $x = 2$. Of course, there is only one even number equal to $2$, so 
\begin{equation*}
\{x \in E: x = 2\} = \{2\}\text{.}
\end{equation*}
\end{example}
\end{document}

在此处输入图片描述

我可以通过改变环境定义以某种方式\qed向上移动一行,到环境的右边吗?equationexample

答案1

使用该ntheorem包,您可以放置​​ \qedsymbol,并且如果使用该选项,automatic可以轻松拥有几种类型的s。该选项与 amsthm 中定义的布局部分兼容,但定义新定理类环境的语法更直观。最后,该选项提供了扩展的引用可能性(与 cleveref 兼容)。\qedsymbolthmmarksamsthmthref

\documentclass[12pt]{extbook}
\usepackage{amsmath, amssymb}
\usepackage[thmmarks, amsmath, thref]{ntheorem}
\theoremstyle{definition}
\theorembodyfont{\normalfont}
\theoremsymbol{\ensuremath{\square}}
\newtheorem{example}{Example}[section]

\begin{document}

\begin{example}
For example, if $E$ is the set of even numbers,
\begin{equation*}
\{x ∈ E: x = 2\}
\end{equation*}
is the set of all even numbers $x$ such that $x = 2$. Of course, there is only one even number equal to $2$, so
\begin{equation*}
\{x ∈ E: x = 2\} = \{2\}\text{.}
\end{equation*}
\end{example}

\end{document} 

在此处输入图片描述

答案2

用显示的材料来结束示例是一种相当糟糕的风格。如果您无法重新表述它,那么有一个示例解决方案。如果您希望将正方形向右移动,您可以用 替换\qed\tag*{\qed}但当然只适用于无编号的方程式。

\documentclass[12pt]{extbook}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{etoolbox}
\theoremstyle{definition}
\newtheorem{example}{Example}[section]
\AtEndEnvironment{example}{\qed}%
\newtheorem{exampleqed}[example]{Example}
\AtEndEnvironment{exampleqed}{}%
%example
\begin{document}

\begin{example}
For example, if $E$ is the set of even numbers,
\begin{equation*}
\{x \in E: x = 2\}
\end{equation*}
is the set of all even numbers $x$ such that $x = 2$. Of course, there is only one even number equal to $2$, so 
\begin{equation*}
\{x \in E: x = 2\} = \{2\}\text{.}
\end{equation*}
\end{example}

\begin{exampleqed}
For example, if $E$ is the set of even numbers,
\begin{equation*}
\{x \in E: x = 2\}
\end{equation*}
is the set of all even numbers $x$ such that $x = 2$. Of course, there is only one even number equal to $2$, so 
\begin{equation*}
\{x \in E: x = 2\} = \{2\}\text{.}
\qed
\end{equation*}
\end{exampleqed}
\end{document}

相关内容