我正在写一篇文章,编辑建议用菱形来结束所有定义。
所以我想知道,是否有一种简单的方法可以自动将命令添加到所有\end{definition}
?我查看了的文档\theoremstyle
,但似乎并没有帮助。
这是一个我手动完成的工作示例......
\documentclass{article}
\usepackage{amssymb}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newcommand{\xqed}[1]{%
\leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
\quad\hbox{\ensuremath{#1}}}
\newcommand{\Endofdef}{\xqed{\lozenge}}
\begin{document}
\begin{definition}
(Stack Overflow) Stack Overflow is a privately held website, the flagship site
of the Stack Exchange Network, created in 2008 by Jeff Atwood and Joel Spolsky,
as a more open alternative to earlier Q\&A sites such as Experts Exchange.\Endofdef
\end{definition}
\end{document}
答案1
定义一个新环境mydef
并在关闭它之前插入符号。
\documentclass{article}
\usepackage{amssymb}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newenvironment{mydef}[1]{%
\begin{definition}#1}{%
\Endofdef\end{definition}%
}
\newcommand{\xqed}[1]{%
\leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
\quad\hbox{\ensuremath{#1}}}
\newcommand{\Endofdef}{\xqed{\lozenge}}
\begin{document}
\begin{mydef}[Stack Overflow] Stack Overflow is a privately held website, the flagship site
of the Stack Exchange Network, created in 2008 by Jeff Atwood and Joel Spolsky,
as a more open alternative to earlier Q\&A sites such as Experts Exchange.
\end{mydef}
\end{document}
答案2
如果您可以考虑使用ntheorem
,那么很容易在任何定理类型环境的末尾合并一个符号。它的优点是它的放置是自动的,即使环境最终显示在显示的方程中:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[thmmarks, amsmath, thref]{ntheorem}
\theoremstyle{plain}
\theoremheaderfont{\bfseries}
\theorembodyfont{\upshape}
\theoremsymbol{\scalebox{1}[1.4]{\large$ \diamond $}}
\newtheorem{definition}{Definition}[section]
\begin{document}
\section{A Demo Section}
\begin{definition}
(Stack Overflow) Stack Overflow is a privately held website, the flagship site
of the Stack Exchange Network, created in 2008 by Jeff Atwood and Joel Spolsky,
as a more open alternative to earlier Q\&A sites such as Experts Exchange.
\end{definition}
\begin{definition}
A \textbf{Pythagorean triple} is a triple $ (x, y, z) $ of integers such that
\[ x² + y² = z² . \]%
\end{definition}
\end{document}