3

Is there a command like \intertext or \shortintertext that has different vertical space above and below the "intertext"? It would be nice in situations such as a few of those in the example below.

\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
  • 1
    Off-topic: Instead of writing \!\left, \!\left[, and \right]\!, I suggest you load the mleftright package in the preamble and write \mleft(, \mleft[, and \mright].
    – Mico
    Mar 22 at 22:05

1 Answer 1

6

You can manually add height or depth.

\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}

I incorporated Mico's suggestion about mleftright.

enter image description here

1
  • +1: I took the liberty to add a link to parenthesis package since it is less known (at least to me). Feel free to reverse the edit if you don't like it. Mar 22 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .