我有一个自定义环境properties
(几乎准备好发布到 Github),其工作方式如下:
\begin{properties}
\item[no max in reals] \forall a \in \Re, \exists b \in \Re : a < b
\item[minimum natural] \exists n \in \Na : \forall m \in \Na, n \le m
\end{properties}
并会产生(无拼写错误)
然而,对于更复杂的例子,间距似乎不对:
\NewDocumentEnvironment
我认为这与我没有考虑到的行为有关……
平均能量损失
\documentclass{article}
\usepackage{amsmath,amsthm} % \text{...}; \newtheorem{...}{...}
\usepackage{xparse,expl3}
\usepackage[hidelinks]{hyperref} % For some reason, this affects
% numbering of the equations.
\ExplSyntaxOn
% makes sure math content is centered
\cs_new:Nn \property_do_fill:
{ \hskip \textwidth minus \textwidth }
% enters math mode and starts a property
% does not typeset a math comment
\cs_new:Nn \property_do_begin:
{
\equation
\quad\bullet
\property_do_fill:
}
% enters math mode and starts a property
% does typeset math comment
\cs_new:Nn \property_do_begin:n
{
\equation
\quad\bullet\enspace\text{\slshape #1}
\property_do_fill:
}
% ends this property and exists math mode
\cs_new:Nn \property_do_end:
{
\property_do_fill:
\endequation
}
\bool_new:N \g_property_first_item_bool
\NewDocumentEnvironment { properties } { }
{
\bool_set_true:N \g_property_first_item_bool
% Delimits properties
% starts off by beginning a property, and then redefines itself
% to end a previous property before starting a new one.
\DeclareDocumentCommand \item { o }
{
\bool_if:NTF \g_property_first_item_bool
{ \bool_set_false:N \g_property_first_item_bool }
{ \property_do_end: }
\IfValueTF { ##1 }
{ \property_do_begin:n { ##1 } }
{ \property_do_begin: }
}
}
{ \property_do_end: }
\theoremstyle{definition}
\newtheorem{definition}{Definition}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Extra %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This stuff isn't necessary for compilation, but is stuff that I use
% in the example. Feel free, of course, to use it in your own stuff
% (LPPL and all that jazz). I find it helps further logicall organize
% stuff, although it acts a little weird with AUCTeX's fold mode.
% Save the old \forall
\cs_set_eq:NN \for_all: \forall
% create a *new* forall that takes two arguments: the predicate and
% the other thing. Because I forgot FOM.
\cs_new:Nn \for_all:nn
{
\for_all: #1,\; #2
}
\DeclareDocumentCommand \forall { s }
{
\IfBooleanTF { #1 }
\for_all:
\for_all:nn
}
% Save the old \exists
\cs_set_eq:NN \exists: \exists
% create a *new* forall that takes two arguments: the predicate and
% the other thing. Because I forgot FOM.
\cs_new:Nn \exists:nn
{
\exists:\,#1:#2
}
\DeclareDocumentCommand \exists { s }
{
\IfBooleanTF { #1 }
\exists:
\exists:nn
}
\ExplSyntaxOff
\def\Na{\mathbf N}
\begin{document}
\begin{definition}[group]
A group is a set $G$ together
with a binary operation $*$ on $G$
that satisfies the following axioms:
\begin{properties}
\item[associativity] \label{def:group:assoc}
\forall{a,b,c \in G}{(a * b) * c = a * (b * c)}
\item[identity] \label{def:group:identity}
\exists{e \in G}{\forall{a \in G}{a * e = a = e * a}}
\item[inverse] \label{def:group:inverse}
\forall{x \in G}{\exists{b \in G}{a * b = b * a = e}}
\end{properties}
\end{definition}
\end{document}
答案1
我认为这是由于你的代码使用
\equation...\endequation
顺序排列,这样第一项下我们有\belowdisplayskip
,其他项下我们有\belowdisplayshortskip
。所以如果我们添加
\belowdisplayskip\belowdisplayshortskip\relax
在新的环境中,问题将至少暂时得到解决。
结果:
更多的:
理想情况下,应该考虑对多个方程使用align
或gather
,因此也许可以使用类似的方法:
\documentclass{article}
\usepackage{amsmath,amsthm} % \text{...}; \newtheorem{...}{...}
\usepackage{xparse,expl3}
\usepackage[hidelinks]{hyperref} % For some reason, this affects
% numbering of the equations.
\ExplSyntaxOn
\cs_new:Nn \property_do_begin:
{
&\quad\bullet&
}
\cs_new:Nn \property_do_begin:n
{
&\quad\bullet\enspace\text{\slshape #1}&
}
\bool_new:N \g_property_first_item_bool
\DeclareDocumentCommand \item { o }
{
\IfValueTF { #1 }
{ \property_do_begin:n { #1 } }
{ \property_do_begin: }
}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Extra %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This stuff isn't necessary for compilation, but is stuff that I use
% in the example. Feel free, of course, to use it in your own stuff
% (LPPL and all that jazz). I find it helps further logicall organize
% stuff, although it acts a little weird with AUCTeX's fold mode.
% Save the old \forall
\cs_set_eq:NN \for_all: \forall
% create a *new* forall that takes two arguments: the predicate and
% the other thing. Because I forgot FOM.
\cs_new:Nn \for_all:nn
{
\for_all: #1,\; #2
}
\DeclareDocumentCommand \forall { s }
{
\IfBooleanTF { #1 }
\for_all:
\for_all:nn
}
% Save the old \exists
\cs_set_eq:NN \exists: \exists
% create a *new* forall that takes two arguments: the predicate and
% the other thing. Because I forgot FOM.
\cs_new:Nn \exists:nn
{
\exists:\,#1:#2
}
\DeclareDocumentCommand \exists { s }
{
\IfBooleanTF { #1 }
\exists:
\exists:nn
}
\ExplSyntaxOff
\def\Na{\mathbf N}
\begin{document}
\begin{definition}[group]
A group is a set $G$ together
with a binary operation $*$ on $G$
that satisfies the following axioms:
\begin{align}
\item[associativity] \label{def:group:assoc}
\forall{a,b,c \in G}{(a * b) * c = a * (b * c)}\\
\item[identity] \label{def:group:identity}
\exists{e \in G}{\forall{a \in G}{a * e = a = e * a}}\\
\item[inverse] \label{def:group:inverse}
\forall{x \in G}{\exists{b \in G}{a * b = b * a = e}}
\end{align}
\end{definition}
\end{document}
查看结果: