参考答案如何将所有证明自动放置在附录中?
例如,我想将“证明...”(放在最后的证明)的样式更改为粗体,但我不想更改文本中其他证明的样式。我该如何实现?
\documentclass[a4paper]{article}
\usepackage{etex,etoolbox}
\usepackage{amsthm,amssymb}
\usepackage{thmtools}
%\usepackage{environ}
\usepackage{indentfirst}
\usepackage{amsmath,amscd}
\usepackage{mathrsfs}
\usepackage{ulem}
\usepackage{bbm}
\usepackage{amsfonts}
\usepackage{hyperref}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{setspace}
\usepackage{color}
\usepackage[nameinlink]{cleveref}
\crefname{ineq}{inequality}{inequalities}
\creflabelformat{ineq}{#2{\upshape(#1)}#3}
\usepackage{enumitem} % do away with indentation on my lists
\crefname{lem}{Lemma}{Lemmas}
\crefname{prop}{Proposition}{Propositions}
\crefname{thm}{Theorem}{Theorems}
\crefname{cor}{Corollary}{Corollaries}
\crefname{ass}{Assumption}{Assumptions}
\crefname{df}{Definiton}{Definitons}
\makeatletter
\providecommand{\@fourthoffour}[4]{#4}
% We define an addition for the theorem-like environments; when
% \newtheorem{thm}{Theorem} is declared, the macro \thm expands
% to {...}{...}{...}{Theorem} and with \@fourthoffour we access
% to it; then we make available \@currentlabel (the theorem number)
% also outside the environment.
\def\fixstatement#1{%
\AtEndEnvironment{#1}{%
\xdef\pat@label{\expandafter\expandafter\expandafter
\@fourthoffour\csname#1\endcsname\space\@currentlabel}}}
% We allocate a block of 1000 token registers; in this way \prooftoks
% is 1000 and we can access the following registers of the block by
% \prooftoks+n (0<n<1000); we'll use a dedicated counter for it
% that is stepped at every proof
\globtoksblk\prooftoks{1000}
\newcounter{proofcount}
% We gather the contents of the proof as argument to \proofatend
% and then we store
% "\begin{proof}[Proof of <theoremname> <theoremnumber>]#1\end{proof}"
% in the next token register of the allocated block
\long\def\proofatend#1\endproofatend{%
\edef\next{\noexpand\begin{proof}[Proof of \pat@label]}%
\toks\numexpr\prooftoks+\value{proofcount}\relax=\expandafter{\next#1\end{proof}}
\stepcounter{proofcount}}
% \printproofs simply loops over the used token registers of the
% block, freeing their contents
\def\printproofs{%
\count@=\z@
\loop
\the\toks\numexpr\prooftoks+\count@\relax
\ifnum\count@<\value{proofcount}%
\advance\count@\@ne
\repeat}
\makeatother
% Here starts the example, with two theorem declarations
\newtheorem{thm}{Theorem}
\newtheorem{lem}[thm]{Lemma}
\fixstatement{thm}
\fixstatement{lem}
\begin{document}
\newtheorem{definition}{Definition}
\newtheorem{cor}[definition]{Corollary}
\begin{proof}[Proof of \cref{addition}]
(state your proof here)
\end{proof}
\begin{lem}\label{addition}
$1+1=2$
\end{lem}
\proofatend
It's quite clear.
\endproofatend
\begin{thm}
$1+2=3$
\end{thm}
\proofatend
Obvious from lemma \cref{addition}.
\endproofatend
\begin{cor}
$1+2=3$
\end{cor}
\appendix
\section[Proof of the Fundamental Theorem of Algebra]
{Proof of \cref{addition}}
\begin{proof}
Assume...
\end{proof}
\section*{Proofs}
\printproofs
\end{document}
附言:加载的包太多了,因为我想确保它们与我正在使用的包没有冲突。
答案1
使用
\long\def\proofatend#1\endproofatend{%
\edef\next{\noexpand\begin{proof}[\noexpand\normalfont\noexpand\bfseries Proof of \pat@label]}%
\toks\numexpr\prooftoks+\value{proofcount}\relax=\expandafter{\next#1\end{proof}}
\stepcounter{proofcount}}
答案2
因为您正在使用amsthm
,所以您可以重新定义proof
环境来为标题字体提供“通用”字体命令,然后在打印校样时替换它:
\newcommand{\proofheadfont}{\itshape}
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
% \itshape
\proofheadfont
#1\@addpunct{.}]\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
\def\printproofs{%
\renewcommand{\proofheadfont}{\bfseries}
...
(我确信这可以通过补丁来完成,但我还无法让它工作。)