我想要一个proof
满足以下约束的环境:
- 证明必须从新队在“证明”一词之后。
- “证明”一词和第一行必须位于同一页面。
- 必须使用的语法是
\begin{proof}...\end{proof}
,因为我已经在许多不同的文档中使用了它。
我读了这里,但我认为它们不能满足我的第二和第三个条件。
此外,我正在编写一些代码并进行了一些更改(我收到了错误报告,这里是日志文件)。
\documentclass{article}
\usepackage{amsmath,amsthm}
\renewenvironment{proof}[1][\proofname]{%I changed \newenvironment to \renewenvironment!!!!
\begin{proof}[#1]$ $\par\nobreak\ignorespaces
}{%
\end{proof}
}
\begin{document}
\begin{proof}[Proof of my theorem]
First line of my proof
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\begin{proof}
First line of my proof
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\end{document}
提前致谢!
答案1
您只需要修补proof
。
\documentclass{article}
\usepackage{amsmath,amsthm}
\usepackage{xpatch}
\xapptocmd{\proof}{\mbox{}\par\nobreak}{}{}
\textheight=6.2cm % just for the example
\begin{document}
\begin{proof}[Proof of my theorem]
First line of my proof.
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\begin{proof}
First line of my proof.
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\begin{proof}
This will be in the next page. Some filler text.
Some filler text. Some filler text. Some filler text.
Some filler text. Some filler text. Some filler text.
Some filler text. Some filler text. Some filler text.
Some filler text. Some filler text. Some filler text.
Some filler text. Some filler text. Some filler text.
Some filler text. Some filler text. Some filler text.
Some filler text. Some filler text. Some filler text.
Some filler text. Some filler text. Some filler text.
Some filler text. Some filler text. Some filler text.
\end{proof}
\end{document}
只是为了测试,如果您尝试删除\nobreak
,您会看到最后的“证明”行会自动出现在底部。
答案2
从您的帖子中,我了解到您需要将标题设置Proof
为一行,并将以下文本设置为下一行(如果不是这样,请纠正我)。如果我是正确的,请尝试使用以下代码:
\documentclass{article}
\usepackage{amsmath,amsthm}
\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
\itshape
#1\@addpunct{.}]~\newline
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
\begin{document}
\begin{proof}[Proof of my theorem]
First line of my proof
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\begin{proof}
First line of my proof
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\end{document}
答案3
您可以申请布鲁诺·勒弗洛克的神奇粉末(见下文),但有一个使用该letltxmacro
包的更简单的解决方案,正如 egreg 所言指出。那么,让我们从更简单的解决方案开始:
重新定义\proof
使用letltxmacro
\documentclass{article}
\usepackage{amsthm}
\usepackage{letltxmacro}
% \usepackage{lipsum} % uncomment to test the behavior at a page break
\makeatletter
\LetLtxMacro{\proof@ORIG}{\proof}
\renewcommand{\proof}[1][\proofname]{%
\proof@ORIG[#1]\mbox{}\par\nobreak
}
\makeatother
\begin{document}
% To test the behavior at a page break, use \lipsum[1-4]\par\lipsum[5][1-11]
% here, then add a few words in order to see the proof pushed to the next page.
\begin{proof}[Proof of my theorem]
First line of my proof.
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\begin{proof}
First line of my proof.
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\end{document}
无需使用letltxmacro
\proof
注意:这并不比前面的更好!使用 的简单重新定义所面临的问题\let
是由于 的可选参数\proof
:(带有两个反斜杠)是由 内部使用的机制\\proof
定义的中间宏;接受 的可选参数作为\newcommand
\newenvironment
\\proof
\proof
分隔参数(TeX 宏没有可选参数的概念——LaTeX 添加了这个概念)。
\\proof:
\long macro:[#1]->\par \pushQED (...)
下面是基于以下内容的代码,可以完成您想要的操作布鲁诺·勒弗洛克的神奇粉末:
\documentclass{article}
\usepackage{amsmath,amsthm}
% \usepackage{lipsum} % uncomment to test the behavior at a page break
% Redefinition that combines <https://tex.stackexchange.com/a/8091> (Bruno Le
% Floch) and <https://tex.stackexchange.com/a/85081> (Barbara Beeton).
% Actually, the latter has been modified a bit here after egreg's feedback.
% ;-)
\expandafter\let\expandafter\oldproof\csname\string\proof\endcsname
\let\oldendproof\endproof
\renewenvironment{proof}[1][\proofname]{%
\oldproof[#1]\mbox{}\par\nobreak
}{%
\oldendproof
}
\begin{document}
% To test the behavior at a page break, use \lipsum[1-4]\par\lipsum[5][1-11]
% here, then add a few words in order to see the proof pushed to the next page.
\begin{proof}[Proof of my theorem]
First line of my proof.
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\begin{proof}
First line of my proof.
Intermediary lines of my proof:
\begin{itemize}
\item next-to-last line
\item last line of my proof
\qedhere
\end{itemize}
\end{proof}
\end{document}