parskip
我正在使用带有环境的包amsthm
,并且我注意到在proof
环境上方和下方添加了额外的间距:
知道如何解决这个问题吗?有人问过类似的问题这里,但从未得到答复。以下是上面使用的最小代码:
\documentclass{article}
\usepackage{lipsum}
\usepackage{fullpage}
\usepackage{amsthm, thmtools}
\usepackage{parskip}
\newtheorem{thm}{Theorem}[]
\begin{document}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{proof}
\lipsum[11]
\end{proof}
\lipsum[11]
\begin{thm}
\lipsum[11]
\end{thm}
\end{document}
答案1
您可以使用包-\parskip
在环境的开头添加垂直空格:proof
etoolbox
\documentclass{article}
\usepackage{lipsum}
\usepackage{fullpage}
\usepackage{amsthm, thmtools}
\usepackage{parskip}
\usepackage{etoolbox}
\AtBeginEnvironment{proof}{\vspace*{-\parskip}}
\newtheorem{thm}{Theorem}[]
\begin{document}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{proof}
\lipsum[11]
\end{proof}
\lipsum[11]
\begin{thm}
\lipsum[11]
\end{thm}
\end{document}
答案2
删除 插入的额外空格proof
,即6pt plus 6pt
。
\documentclass{article}
\usepackage{lipsum}
\usepackage{fullpage}
\usepackage{amsthm, thmtools}
\usepackage{parskip}
\newtheorem{thm}{Theorem}
\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont \topsep\z@skip % <---- changed here
\trivlist
\item[\hskip\labelsep
\itshape
#1\@addpunct{.}]\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
\begin{document}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{proof}
\lipsum[11]
\end{proof}
\lipsum[11-12]
\begin{thm}
\lipsum[11]
\end{thm}
\end{document}
不过,既然您正在使用thmtools
,那么就需要更强大的功能。
\documentclass{article}
\usepackage{lipsum}
\usepackage{fullpage}
\usepackage{amsthm, thmtools}
\usepackage{parskip}
\usepackage{xpatch}
\newtheorem{thm}{Theorem}
\makeatletter
%\xpatchcmd{\proof}{6\p@\@plus6\p@\relax}{\z@skip}{}{} % if not using thmtools
% with thmtools it's a bit more complicated
\expandafter\xpatchcmd\csname\string\proof\endcsname{6\p@\@plus6\p@\relax}{\z@skip}{}{}
\makeatother
\begin{document}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{proof}
\lipsum[11]
\end{proof}
\lipsum[11-12]
\begin{thm}
\lipsum[11]
\end{thm}
\end{document}
答案3
您可以重新定义环境以在开头和结尾proof
添加。\vspace{-\parskip}
\documentclass{article}
\usepackage{lipsum}
\usepackage{fullpage}
\usepackage{amsthm, thmtools}
\usepackage{parskip}
\let\oldproof\proof
\let\endoldproof\endproof
\renewenvironment{proof}{%
\vspace{-\parskip}\begin{oldproof}%
}{%
\end{oldproof}\vspace{-\parskip}%
}
\newtheorem{thm}{Theorem}[]
\begin{document}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{thm}
\lipsum[11]
\end{thm}
\begin{proof}
\lipsum[11]
\end{proof}
\lipsum[11]
\begin{thm}
\lipsum[11]
\end{thm}
\end{document}