mathtools \intertext 上方和下方的空间不同

mathtools \intertext 上方和下方的空间不同

\intertext是否有类似或的命令\shortintertext,使“文本间”上方和下方的垂直空间不同?在以下示例中的某些情况下,这会很好。

\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}
  \begin{align*}
    a^2 + b^2 &= c^2 \\
    \shortintertext{and also} % shortintertext works fine
    a^2 + b^2 &= c^2 \\
    \shortintertext{and also} % space above should be as shortintertext and space below should be as intertext
    \sum_{i = 1}^{N} \sum_{j = 1}^{N} \frac{\omega_{i} \omega_{j} Y_{i}}{Y} \!\left(2 \Phi\!\left[\frac{\ln Y_{i} - \ln Y_{j} + 0.5 \sigma_{i}^{2} + 0.5 \sigma_{j}^{2}}{\sqrt{\sigma_{i}^{2} + \sigma_{j}^{2}}}\right]\! - 1\right) &= 0.5 \\
    \intertext{and also} % intertext works fine
    \sum_{i = 1}^{N} \sum_{j = 1}^{N} \frac{\omega_{i} \omega_{j} Y_{i}}{Y} \!\left(2 \Phi\!\left[\frac{\ln Y_{i} - \ln Y_{j} + 0.5 \sigma_{i}^{2} + 0.5 \sigma_{j}^{2}}{\sqrt{\sigma_{i}^{2} + \sigma_{j}^{2}}}\right]\! - 1\right) &= 0.5 \\
    \shortintertext{and also} % space above should be as intertext and space below should be as shortintertext
    a^2 &= c^2 - b^2 \\
  \end{align*}
\end{document}

答案1

您可以手动添加高度或深度。

\documentclass{article}
\usepackage{amsmath,mathtools}
\usepackage{mleftright} % https://www.ctan.org/pkg/mleftright
\mleftright

\newcommand{\addheight}[1]{\rule{0pt}{\dimexpr\ht\strutbox+#1}}
\newcommand{\adddepth}[1]{\rule[-#1]{0pt}{0pt}}

\begin{document}
  \begin{align*}
    a^2 + b^2 &= c^2 \\
    \shortintertext{and also} % shortintertext works fine
    a^2 + b^2 &= c^2 \\
    \shortintertext{and also\adddepth{1.5ex}} % space above should be as shortintertext and space below should be as intertext
    \sum_{i = 1}^{N} \sum_{j = 1}^{N} \frac{\omega_{i} \omega_{j} Y_{i}}{Y} \left(2 \Phi\left[\frac{\ln Y_{i} - \ln Y_{j} + 0.5 \sigma_{i}^{2} + 0.5 \sigma_{j}^{2}}{\sqrt{\sigma_{i}^{2} + \sigma_{j}^{2}}}\right] - 1\right) &= 0.5 \\
    \intertext{and also} % intertext works fine
    \sum_{i = 1}^{N} \sum_{j = 1}^{N} \frac{\omega_{i} \omega_{j} Y_{i}}{Y} \left(2 \Phi\left[\frac{\ln Y_{i} - \ln Y_{j} + 0.5 \sigma_{i}^{2} + 0.5 \sigma_{j}^{2}}{\sqrt{\sigma_{i}^{2} + \sigma_{j}^{2}}}\right] - 1\right) &= 0.5 \\
    \shortintertext{and also\addheight{1.5ex}} % space above should be as intertext and space below should be as shortintertext
    a^2 &= c^2 - b^2
  \end{align*}
\end{document}

我采纳了 Mico 的建议mleftright

在此处输入图片描述

相关内容