我的论文空间不够,所以我想在附录中放一些定理证明,但我也想把“证明在附录中”这句话放在与定理陈述同一行。
\documentclass{article}
\usepackage{amsthm,thmtools}
\declaretheorem[name=Theorem]{thm}
\begin{document}
\section{Body}
\begin{restatable}[Goldbach's conjecture]{thm}{goldbach}
\label{thm:goldbach}
Every even integer greater than 2 can be expressed as the sum of two primes.
{\em (Proof in appendix)}
\end{restatable}
\newpage\appendix
\section{Appendix}
\goldbach*
\begin{proof}
It is trivial.
\end{proof}
\end{document}
我得到的是:
我想要的是:
我应该怎么办?
感谢您的帮助。
答案1
\IfRestatementTF{<true>}{<false>}
<true>
在重述中使用时会离开,<false>
否则会离开。请注意只在-定义定理中使用它thmtools
,因为它的实现不是那么健壮。
\documentclass{article}
\usepackage{amsthm,thmtools}
\declaretheorem[name=Theorem]{thm}
\makeatletter
\newcommand\IfRestateTF{%
\ifx\label\thmt@gobble@label % or just compared to \@gobble
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\makeatother
\begin{document}
\section{Body}
\begin{restatable}[Goldbach's conjecture]{thm}{goldbach}
\label{thm:goldbach}
Every even integer greater than 2 can be expressed as the sum of two primes.
\IfRestateTF{This is restatement.}{This is the original statement. \emph{(Proof in appendix)}}
\end{restatable}
%\newpage
\appendix
\section{Appendix}
\goldbach*
\begin{proof}
It is trivial.
\end{proof}
\end{document}
答案2
定义一个命令\proofinappendix
,您可以在\appendix
启动时重新定义该命令。
\documentclass{article}
\usepackage{amsthm,thmtools}
\declaretheorem[name=Theorem]{thm}
\newcommand{\proofinappendix}{%
\unskip\textup{ (Proof in appendix)}%
}
\AddToHook{cmd/appendix/before}{\renewcommand{\proofinappendix}{\unskip}}
\begin{document}
\section{Body}
\begin{restatable}[Goldbach's conjecture]{thm}{goldbach}
\label{thm:goldbach}
Every even integer greater than $2$ can be expressed as the sum of two primes.
\proofinappendix
\end{restatable}
\appendix
\section{Appendix}
\goldbach*
\begin{proof}
It is trivial.
\end{proof}
\end{document}
答案3
由于restatable
-environments 不能嵌套,因此您可以检查- 但如果在嵌套\@currenvir
环境之外的环境中使用,则会失败:restatable
restatable
\documentclass{article}
\usepackage{amsthm,thmtools}
\declaretheorem[name=Theorem]{thm}
\makeatletter
\newcommand*\restatableenvname{restatable}%
\newcommand\AtIfInRestateableEnvTF{%
\ifx\@currenvir\restatableenvname
\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
}%
\makeatother
\begin{document}
\section{Body}
\begin{restatable}[Goldbach's conjecture]{thm}{goldbach}
\label{thm:goldbach}
Every even integer greater than 2 can be expressed as the sum of two primes.%
\AtIfInRestateableEnvTF{ {\em (Proof in appendix)}}%
{}%
\end{restatable}
\newpage\appendix
\section{Appendix}
\goldbach*
\begin{proof}
It is trivial.
\end{proof}
\end{document}
答案4
我想到最简单的解决方案就是\proofinappendix
在附录中重新定义一个命令,使其没有任何内容:
\documentclass{article}
\usepackage{amsthm,thmtools}
\declaretheorem[name=Theorem]{thm}
\newcommand\proofinappendix{\em (Proof in appendix)}
\begin{document}
\section{Body}
\begin{restatable}[Goldbach's conjecture]{thm}{goldbach}
Every even integer greater than 2 can be expressed as the sum of two primes.
\proofinappendix
\end{restatable}
\appendix
\renewcommand\proofinappendix{}
\section{Appendix}
\goldbach*
\begin{proof}
It is trivial.
\end{proof}
\end{document}