如何在下面的最小示例中减少证明环境头和枚举环境之间的空间?
注意:这很可能不是重复的问题。不久前,我在这里发布了这个问题(如何抑制定理头和枚举环境之间的垂直空间?)。然后在 ( 下提供了有关嵌套枚举环境的修复。嵌套枚举(enumitem)会干扰抑制定理头后的垂直空间。)。最后,有一个后续缺陷,已在
(调整后的)枚举出现奇怪的垂直间距问题
我在这里提到了这一点。这种方法对我很有用,但突然间(我不知道为什么),空间又变得太大了。我尝试调整+0.3em
,但这并没有改变任何垂直空间。
\documentclass{scrartcl}
\usepackage[american]{babel}
\usepackage{enumitem}
\usepackage{etoolbox}
\usepackage{amsthm}
\newif\ifstarttheorem
% proofs
% see https://tex.stackexchange.com/questions/66739/how-to-suppress-vertical-space-between-proof-environment-heads-and-itemize-envir/makeatletter
\makeatletter% q.e.d. adjustment (posted by ???)
\renewenvironment{proof}[1][Proof]{\par
\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries #1]\gdef\mycurrenvir{proof}\global\starttheoremtrue\mbox{}\hfill\\*\ignorespaces
}{%
\gdef\mycurrenvir{\relax}
\popQED\endtrivlist\@endpefalse
}
\makeatother
% suppress vertical spacing (for itemize) when newtheorems start with an environment
% see https://tex.stackexchange.com/questions/122018/weird-vertical-spacing-problem-with-adjusted-enumerate
\makeatletter
\preto\enumerate{%
\if@inlabel
\ifstarttheorem
\mbox{}\par\nobreak\vskip\glueexpr-\parskip-\baselineskip+0.3em\relax\hrule\@height\z@
\fi
\fi
\global\starttheoremfalse
\def\tempa{proof}%
\ifx\tempa\mycurrenvir
\ifstarttheorem
\mbox{}\par\nobreak\vskip\glueexpr-\parskip-\baselineskip+0.3em\relax\hrule\@height\z@
\fi
\fi
\global\starttheoremfalse
}
\preto\endenumerate{\global\starttheoremfalse}
\makeatother
\begin{document}
Some text
\begin{proof}
\begin{enumerate}
\item Proof ...
\end{enumerate}
\end{proof}
\end{document}
更新:
Karl 答案的第二部分有效,令人惊讶的是没有 -part \appto
。然而,我意识到引入了一个虚假的(水平)空格/缩进。最小化这个例子,我最终得到以下内容:
\documentclass{scrartcl}
\usepackage[american]{babel}
\usepackage{amsthm}
\newif\ifstarttheorem
% proofs
% see https://tex.stackexchange.com/questions/173158/how-to-reduce-vertical-spacing-between-proof-environment-and-enumerate-environme
\makeatletter
\renewenvironment{proof}[1][Proof]{\par
\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist\item[\hskip\labelsep\sffamily\bfseries #1]\ignorespaces\global\starttheoremtrue\mbox{}\vskip0pt\noindent
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
\begin{document}
\noindent Proof with an optional argument:
\begin{proof}[Alternative]
Why is there a space before "Why"?
\end{proof}
\end{document}
答案1
你可以简单地重新定义proof
这样
\makeatletter% q.e.d. adjustment (posted by ???)
\renewenvironment{proof}[1][Proof]{\par
\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries #1]\ignorespaces\mbox{}\vskip0pt\noindent
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
topsep=0
并在调用时使用enumerate
。
平均能量损失
\documentclass{scrartcl}
\usepackage[american]{babel}
\usepackage{enumitem}
\usepackage{etoolbox}
\usepackage{amsthm}
% proofs
% see http://tex.stackexchange.com/questions/66739/how-to-suppress-vertical-space-between-proof-environment-heads-and-itemize-envir/makeatletter
\makeatletter% q.e.d. adjustment (posted by ???)
\renewenvironment{proof}[1][Proof]{\par
\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries #1]\ignorespaces\mbox{}\vskip0pt\noindent
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
% suppress vertical spacing (for itemize) when newtheorems start with an environment
% see http://tex.stackexchange.com/questions/122018/weird-vertical-spacing-problem-with-adjusted-enumerate
\begin{document}
Some text
\begin{proof}
\begin{enumerate}[topsep=0pt]
\item Proof ...
\end{enumerate}
\end{proof}
Some text
\begin{proof}
Some text
\end{proof}
\end{document}
输出
编辑
无需解决方案enumitem
\documentclass{scrartcl}
\usepackage[american]{babel}
\usepackage{etoolbox}
\usepackage{amsthm}
\newif\ifstarttheorem
% proofs
% see http://tex.stackexchange.com/questions/66739/how-to-suppress-vertical-space-between-proof-environment-heads-and-itemize-envir/makeatletter
\makeatletter% q.e.d. adjustment (posted by ???)
\renewenvironment{proof}[1][Proof]{\par
\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries #1]\ignorespaces\global\starttheoremtrue\mbox{}\vskip0pt\noindent
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
% suppress vertical spacing (for itemize) when newtheorems start with an environment
% see http://tex.stackexchange.com/questions/122018/weird-vertical-spacing-problem-with-adjusted-enumerate
\makeatletter
\appto\enumerate{%
\ifstarttheorem
\vspace{-.5\baselineskip}
\fi
\global\starttheoremfalse
}
\preto\endenumerate{\global\starttheoremfalse}
\makeatother
\begin{document}
Some text
\begin{proof}
\begin{enumerate}
\item Proof ...
\end{enumerate}
\end{proof}
Some text
\begin{proof}
Some text
\end{proof}
\end{document}
输出: