I need to get better control on the abovedisplayshortskip when the last text line is shorter than the equation below it. My current solution is an hack and is ackward to use. See for example the MWE example below and its preview picture:
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[nomath]{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot,showframe]{geometry}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.1}
\raggedbottom
\usepackage{microtype}
\usepackage{nccmath,amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}
\newcommand*{\topless}{\vspace{\glueexpr\abovedisplayshortskip-\abovedisplayskip}}
\begin{document}
\setlength{\abovedisplayskip}{2ex}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayskip}{\abovedisplayskip}
\setlength{\belowdisplayshortskip}{\belowdisplayskip}
\setlength{\jot}{3ex}
\noindent
This is just a test, to see what will happen next and the equation below this dummy text sample:
\begin{align}
y^2 + x^2 - z^2 = 1
\end{align}
This is just a test, to see what will happen next and the equation below this dummy text sample:
\topless
\begin{align}
y^2 + x^2 - z^2 = 1
\end{align}
This is just a test, to see what will happen next and the equation below this dummy text sample:
\begin{equation}
y^2 + x^2 - z^2 = 1
\end{equation}
This is just a test, to see what will happen next and the equation below this dummy text sample which has no meaning:
\begin{equation}
y^2 + x^2 - z^2 = 1
\end{equation}
This is just a test, to see what will happen next and the equation below this dummy text sample which has no meaning at:
\begin{equation}
y^2 + x^2 - z^2 = 1
\end{equation}
This is just a test, to see what will happen next and the equation below this dummy text sample which has no meaning at:
\topless
\begin{equation}
y^2 + x^2 - z^2 = 1
\end{equation}
This is just a test, to see what will happen next and the equation below this dummy text sample:
\begin{gather}
y^2 + x^2 - z^2 = 1
\end{gather}
\end{document}
Preview showing the problem in red:

Currently, I could reduce the vertical space of equations (1), (5) and (7) by using the macro that I called \topless, but this is really ackward since I need to predict the spacing problem. I could use that command only after a first compilation, and it's not very reliable (especially if I need to change the text or font size, for example).
I need an automatic solution, at the preamble level, for any environment (equation, align, gather, etc).
As you can see on the preview, the equation environment has a better tolerance to the displayshortskip minimal limit (see (3), (4), and (5). The overlap limit is small), while the align and gather environments have a much lower tolerance (the overlap limit is pretty large!). I hate that! I want to get rid of my hack style macro, but still reduce the vertical spacing when the last text line is close to the displayed equation below it. My limit would be 1ex in size.
Can we have access to the size limit that LaTeX uses to change the vertical spacing, when the end of the last text line is close to the display? I want to reduce that limit to about 1ex size. Is this possible? If so, how could we implement this in the preamble?
\halignthat is the width of the page. – David Carlisle Jan 05 '20 at 16:01equationis fixed in tex at 2em and is not changeable without changing the source of tex-the-program – David Carlisle Jan 05 '20 at 16:02\pdfsaveposat the end of the paragarph and at the start of the first row of math, then if you write the\pdflastxposof each to the aux file then on the next run you can check their relative positions and adjust the vertical space if necessary. perhaps.... – David Carlisle Jan 05 '20 at 16:09\eqalignautomatically detects when and when not to useabovedisplayshortskip: see Barbara Beeton's response to this comment.) – Gabriel A. Lozada Jun 27 '23 at 19:12\eqalignaren't you? likealignthat is a full width\halign– David Carlisle Jun 27 '23 at 19:20\documentclass{article} \usepackage{plain} \begin{document} \showboxbreadth=\maxdimen \showboxdepth=3 \tracingoutput=1 \tracingonline=1 Hello world! \begin{plain} $$\eqalign{x &= 1 \cr y &= 2.}$$ Hello Hello Hello Hello Hello Hello Hello Hello Hello $$\eqalign{x &= 1 \cr y &= 2.}$$ \end{plain} \end{document}shows\abovedisplayshortskipand\belowdisplayshortskipfor the first alignment and\abovedisplayskipand\belowdisplayskipfor the second alignment. – Gabriel A. Lozada Jun 27 '23 at 19:36\eqalignno, which (unlike Plain's\eqalign) does not automatically detect when and when not to useabovedisplayshortskip. – Gabriel A. Lozada Jun 27 '23 at 20:02