我正在尝试排版 Leslie Lamport 在其论文中所展示的结构化证明 如何撰写 21 世纪证明。具体来说,我正在尝试排版图 3(如下所示)。
我的代码和输出如下所示。
\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{enumitem}
% LSP is short for Lamport Structured Proof
\newlist{lsp}{enumerate}{10}
\setlist[lsp]{label=\arabic*.}
\newcommand{\lspproof}{{\scshape Proof:\ \ }}
\newcommand{\lspqed}{Q.E.D.}
\newtheorem{corollary}{Corollary}
\begin{document}
\begin{corollary}
If $f'(x) > 0$ for all $x$ on an interval $I$,
then $f$ is increasing on $I$.
\end{corollary}
\begin{lsp}
\item It suffices to assume
\begin{lsp}
\item $a$ and $b$ are points in $I$
\item $a < b$
\end{lsp}
\lspproof By definition of an increasing function
\item There is some $x$ in $(a,b)$
with $\displaystyle f'(x) = \frac{f(b)-f(a)}{b-a}$.\\*
\lspproof By assumptions 1.1 and 1.2,
the hypothesis that $f$ is differentiable on $I$,
and the Mean Value Theorem.
\item $f'(x) > 0$ for all $x$ in $(a,b)$.\\*
\lspproof By the induction hypothesis of the corollary and assumption 1.1.
\item $\displaystyle \frac{f(b)-f(a)}{b-a} > 0$\\*
\lspproof By 2 and 3.
\item \lspqed\\*
\lspproof Assumption 1.2 implies $b - a > 0$,
so 4 implies $f(b) - f(a) > 0$,
which implies $f(b) > f(a)$.
By 1, this proves the corollary
\end{lsp}
\end{document}
虽然我对结果很满意,但我发现有点烦人,因为我必须手动告诉 LaTeX 使用\\*
before each来开始新行\lspproof
。
问题:
- 有没有办法定义
\lspproof
,以便在需要时自动开始新行?请注意,我不需要\\*
在步骤 1 中的“证明:”之前插入,因为“证明:”出现在枚举环境之后。 - 有没有办法稍微增加“证明。”
\lspproof
和上一行之间的垂直空间?
答案1
以下是使用段落分隔符而不是强制换行符的一个选项:
\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath,amsthm,enumitem}
% LSP is short for Lamport Structured Proof
\newlist{lsp}{enumerate}{10}
\setlist[lsp]{label=\arabic*.,ref=\arabic*}
\newcommand{\lspproof}{\par\nobreak{\scshape Proof:}\quad}
\newcommand{\lspqed}{Q.E.D.}
\newtheorem{corollary}{Corollary}
\begin{document}
\begin{corollary}
If $f'(x) > 0$ for all $x$ on an interval~$I$, then $f$ is increasing on~$I$.
\end{corollary}
\begin{lsp}
\item It suffices to assume \label{proof1}
\begin{lsp}
\item $a$ and~$b$ are points in~$I$ \label{assump1}
\item $a < b$ \label{assump2}
\end{lsp}
\lspproof By definition of an increasing function.
\item There is some~$x$ in $(a,b)$ with $ f'(x) = \dfrac{f(b)-f(a)}{b-a}$. \label{proof2}
\lspproof By assumptions~\ref{proof1}.\ref{assump1} and~\ref{proof1}.\ref{assump2}, the hypothesis that~$f$ is differentiable on~$I$,
and the Mean Value Theorem.
\item $f'(x) > 0$ for all $x$ in $(a,b)$. \label{proof3}
\lspproof By the induction hypothesis of the corollary and assumption~\ref{proof1}.\ref{assump1}.
\item $\dfrac{f(b)-f(a)}{b-a} > 0$ \label{proof4}
\lspproof By~\ref{proof2} and~\ref{proof3}.
\item \lspqed
\lspproof Assumption~\ref{proof1}.\ref{assump2} implies $b - a > 0$, so~\ref{proof4} implies $f(b) - f(a) > 0$, which implies $f(b) > f(a)$.
By~\ref{proof1}, this proves the corollary
\end{lsp}
\end{document}