我希望有一个环境,其中没有在显示模式方程后插入以下显示跳过。定义
\newenvironment{NoBelowDisplaySkip}{%
\begingroup
\belowdisplayskip=0pt\relax%
\belowdisplayshortskip=0pt\relax%
}{%
\endgroup
}
运行正常。但是,当我尝试使用 时\intertext{}
,在 开始之前缺少垂直空间\intertext{}
(见红色文本):
代码:
\documentclass{article}
\usepackage{mathtools}
\usepackage{xcolor}% so I can highlight where the problem is
\pagecolor{white}
\newenvironment{NoBelowDisplaySkip}{%
\begingroup
\belowdisplayskip=0pt\relax%
\belowdisplayshortskip=0pt\relax%
}{%
\endgroup
}
\newcommand*{\MyText}[1]{%
\begin{align*}
F &= ma \\
\intertext{\color{#1}and another not totally unrelated equation}
E &= mc^2.
\end{align*}
Some follow on text%
}
\begin{document}
Normal \verb|{align*}| with \verb|\intertext{}|
\MyText{black}.
% ----------
Repeat, but wrapped in the \verb|{NoBelowDisplaySkip}| environment:
\begin{NoBelowDisplaySkip}%
\MyText{red}
\end{NoBelowDisplaySkip}.%
\end{document}
答案1
\intertext
\abovedisplayskip
与上面和下面的公式不仅使用和\belowdisplayskip
(及其短版本)分开,还使用\l_MT_above_intertext_sep
和\l_MT_below_intertext_sep
。它们可以调整,但结果并不完全相同,因为它们是 dimens,而不是 skips,所以它们不能缩小或拉伸。以下示例分配\l_MT_above_intertext_sep
的值\belowdisplayskip
(以及短版本)。另一个变化是您实际上不需要\begingroup
和,\endgroup
因为环境会自动形成一个组。
\documentclass{article}
\usepackage{mathtools}
\usepackage{xcolor}% so I can highlight where the problem is
\pagecolor{white}
\catcode`\_=11
\newenvironment{NoBelowDisplaySkip}{%
\l_MT_above_intertext_sep=\belowdisplayskip
\l_MT_above_shortintertext_sep=\belowdisplayshortskip
\belowdisplayskip=0pt
\belowdisplayshortskip=0pt
}{%
}
\catcode`\_=8
\newcommand*{\MyText}[1]{%
\begin{align*}
F &= ma \\
\intertext{\color{#1}and another not totally unrelated equation}
E &= mc^2.
\end{align*}
Some follow on text%
}
\begin{document}
Normal \verb|{align*}| with \verb|\intertext{}|
\MyText{black}.
% ----------
Repeat, but wrapped in the \verb|{NoBelowDisplaySkip}| environment:
\begin{NoBelowDisplaySkip}%
\MyText{red}
\end{NoBelowDisplaySkip}.
Again normal \verb|{align*}| with \verb|\intertext{}|
\MyText{black}.
\end{document}