[Tex/LaTex] Reduce space between equations and text

amsmathline-spacingmathtoolsspacing

I am writing some sentences which contain numbered displayed equations in the middle, like this one:

|  Consider the relationship:      |
|      EQUATION                 (1)|
|where x is ... and y is ...       |
|                                  |
|  This is a new paragraph which   |
|ends with the following:          |
|      EQUATION                 (2)|
|                                  |
|  And this is the last paragraph, |
|followed by some equations which  |
|are not part of it.               |
|                                  |
|      EQUATIONS                (3)|
|                                  |
|  The end.                        |

This is the code, with empty line between paragraphs:

Consider the relationship:
\begin{equation} ... \end{equation}
where x is ... and y is ...

This is a new paragraph which ends with the following:
\begin{equation} ... \end{equation}

And this is the last paragraph, followed by some equations which are not part of it.

\begin{equation} ... \end{equation}

The end.

I'd like to reduce the space between the equation and the text, but only in those cases in which the equation is in the middle of the sentence (note the vertical spacing and the paragraph indentations in the example above). Is there any way to do that, whitout changing global spacing like here?

The ideal solution would be something that recognize whether the equation is part or a paragraph or not (i.e. based on the blank lines between two paragraphs, like the indentation). Alternatively, a command to insert before, inside or before+after the equation (and gathered, align, …) environments, or a new environment like \begin{NoSpaceEquation} ... \end{NoSpaceEquation}, is fine too.

I'm not looking for solutions like a global space reduction, which would need to manually add space before and after isolated equations. The solution should affects only the equations inside a paragraph.

PS: I am using mathtools.

Thank you!

Best Answer

You can use the \useshortskip command from nccmath (just before the equation) or \SwapAboveDisplaySkip (at the very beginning of an amsmath environment):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools, nccmath}

\begin{document}

In the first place, consider the relationship:
\begin{equation}\textit{A first equation} \end{equation}
where x is ... and y is ...

This is a new paragraph which ends with the following equation:\useshortskip
\begin{equation}\textit{Another equation} \end{equation}

This is another paragraph which ends with an AmSmath environment:
\begin{gather}\SwapAboveDisplaySkip\textit{Another equation} \end{gather}

And this is the last paragraph, followed by some equations which are not part of it.

\begin{equation}\textit{Still another equation}.\end{equation}

The end.

\end{document} 

enter image description here

To reduce the spacing above and below an equation, we can patch an internal command of nccmath, but the following text must not start a new paragraph:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools, nccmath}

\usepackage{xpatch}
\xpatchcmd{\NCC@ignorepar}{%
\abovedisplayskip\abovedisplayshortskip}
{%
\abovedisplayskip\abovedisplayshortskip%
\belowdisplayskip\belowdisplayshortskip}
{}{}

\begin{document}

In the first place, consider the relationship:
\begin{equation}\textit{A first equation} \end{equation}
where x is ... and y is ...

This is a new paragraph which ends with the following equation:\useshortskip
\begin{equation}\textit{Another equation}\text{(spacing with \texttt{\textbackslash useshortskips})}\end{equation}

And this is the last paragraph, followed by some equations which are not part of it.

\begin{equation}\textit{Still another equation}.\end{equation}

The end of this very exhaustive test.

\end{document} 

enter image description here

Related Question