標記定義的結尾

標記定義的結尾

我使用該amsthm套件來定義definition環境,如下所示:

\theoremstyle{definition}
\newtheorem{definition}{Definition}

令我驚訝的是,這幾乎沒有提供任何關於定義結束位置和以下文字起始位置的印刷指示(有一個新段落,但這顯然還不夠,特別是當定義以方程式結尾時)。

我該怎麼做才能讓這一點更清楚?我不希望定義文字的字體與普通文字的字體不同。也許一個定義,就像一個證明,應該以\qedsymbol- 我該如何添加這個結尾?

答案1

amsthm本身並不是最好的;然而,thmtoolsamsthm為和其他定理包提供了一個非常簡潔的「前端」 。

特別是,thmtools包括可以滿足您的需求的prefoothook和。下面是一個結合postfoothook使用的小用例,它用一條簡單的水平線完成了範例。您可以輕鬆地根據您的需求進行調整。例如,您可以將其與thmtoolsamsthmtcolorbox對於非常奇特的框,或者您可以向右刷新文字“範例結束”。

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}

\declaretheoremstyle[
  headfont=\normalfont\scshape,
  numbered=unless unique,
  bodyfont=\normalfont,
  spaceabove=1em plus 0.75em minus 0.25em,
  prefoothook=\newline\rule{\linewidth}{1pt},
  spacebelow=1em plus 0.75em minus 0.25em,
]{exmpstyle}

\declaretheorem[
  style=exmpstyle,
  title=Example,
  refname={example,examples},
  Refname={Example,Examples}
]{exmp}

\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut pustibulum ut,
placerat ac, adipiscing vitae, felis. Curabitur dictum uris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, nec vehicula augue eu
neque. Pellentesque habitant morbi tristique t netus et malesuada fames ac
turpis egestas. Mauris ut leo.
\begin{exmp}
  \lipsum*[1]
\end{exmp}
\lipsum[2-3]
\begin{exmp}
  \lipsum*[4]
\end{exmp}
\end{document}

和輸出:

輸出

附錄

正如 Caramdir 所提到的以及 Barbara Beeton 在評論中所要求的,這裡是一個使用方程式並使用該qed選項的範例:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}

\declaretheoremstyle[
  headfont=\normalfont\bfseries\itshape,
  numbered=unless unique,
  bodyfont=\normalfont,
  spaceabove=1em plus 0.75em minus 0.25em,
  spacebelow=1em plus 0.75em minus 0.25em,
  qed={\itshape That's All Folks!},
]{exmpstyle2}

\declaretheorem[
  style=exmpstyle2,
  title=Example,
  refname={example,examples},
  Refname={Example,Examples}
]{exmp2}

\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut pustibulum ut,
placerat ac, adipiscing vitae, felis. Curabitur dictum uris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, nec vehicula augue eu
neque. Pellentesque habitant morbi tristique t netus et malesuada fames ac
turpis egestas. Mauris ut leo.
\begin{exmp2}
  \lipsum*[1]
\end{exmp2}
\lipsum[2-3]
\begin{exmp2}
  \lipsum*[4]
  \begin{equation*}
    \mathcal{L} = \overline \psi (i \gamma \cdot \partial - m) \psi
    \qedhere
  \end{equation*}
\end{exmp2}
\end{document}

其產生:

輸出2

答案2

我實在看不出有什麼必要。但既然你這麼問了

\documentclass{article}
\usepackage{amsthm}

\usepackage{lipsum}

\theoremstyle{definition}
\newtheorem{defi/}{Definition}

\newenvironment{defi}
  {\renewcommand{\qedsymbol}{$\heartsuit$}%
   \pushQED{\qed}\begin{defi/}}
  {\popQED\end{defi/}}

\begin{document}

\lipsum[2]

\begin{defi}
This is the definition of \emph{definition}.
\end{defi}

\lipsum[3]

\begin{defi}
This is the definition of recursion,
\[
x\gets x+1 \qedhere
\]
\end{defi}

\lipsum[2]

\end{document}

在此輸入影像描述

我只是假設你在定義中沒有證據。

答案3

thmbox包裹提供了一種顯示theorem類似環境的好方法。

例如,使用三種預定義樣式,您可以:

\documentclass{article}
\usepackage{mathtools}
\usepackage{thmbox} % Overrides \newtheorem command! See [nothm] to disable this feature.
\usepackage{lipsum} % Useless, just for the demo.

\newtheorem[S, bodystyle=\normalfont\noindent]{defiS}{Definition}[section]
\newtheorem[M]{defiM}{Definition}[section]
\newtheorem[L]{defiL}{Definition}[section]

\begin{document}

\section{My nice demo}

\begin{defiS}[Inverse of a relation]
  Let \(R\) be a relation, \emph{the inverse of \(R\)} is
  \[R^{-1} = \{(x,y) \mid (y, x) \in R\}\]
\end{defiS}

\lipsum[2] % Just for the demo

\begin{defiM}[Union]
  Let \(R\) and \(S\) be relations, the \emph{union of \(R\) and \(S\)} is defined as
  \[
  R \cup S = \{(x, y) \mid (x,y) \in R \text{ or } (x,y) \in S\}
  \]
\end{defiM}

\lipsum[1] % Just for the demo

\begin{defiL}[Graph of a function]
  Let \(f\) be a fuction, the \emph{graph of \(f\)}  is
  \[
  \langle f \rangle = \{(x, y) \mid f x = y\}
  \]
\end{defiL}

\end{document}

在此輸入影像描述

請注意:

  • 我僅將第一個範例(環境)的字體設定為normalfont(即不傾斜)defiS
  • 三種情況下的編號為 1.1,因為我使用了三種不同的環境(即defiSdefiMdefiL),但如果您堅持使用一種環境,數字將是正確的(即 1.1、1.2、1.3 等)。
  • 我只是使用了預先定義的樣式,但是您可以自訂它們很多。

答案4

一種解決方案是縮排(按給定量)整個證明並稍微調整字體大小。您可以考慮對環境進行以下重新定義proof

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont\small\topsep6\p@\@plus6\p@\relax
%\trivlist %%%% old
\list{}{\leftmargin=\parindent
   \rightmargin=0pt
   \settowidth{\itemindent}{\itshape#1}%
   \labelwidth=\itemindent}  
\item[\hskip\labelsep\itshape#1\@addpunct{.}]\ignorespaces
}{%
 \popQED
 %\endtrivlist %%OLD
 \endlist %%NEW
 \@endpefalse
}
\makeatother

相關內容