# Redefine align to include SwapAboveDisplaySkip by default

I have several documents that I am looking to reduce redundant whitespace in and am looking to redefine align to include SwapAboveDisplaySkip from mathtools by default. Since I want to use it almost everywhere, I'd rather not have to manually include it everywhere.

Currently I have the following, which does what I want, except for a new environment rather than for align, which is essentially just the solution from here: Define a custom align, and align* environment

\documentclass{article}
\usepackage{amsmath, mathtools}

\makeatletter
\newenvironment{salign}
{\par\align \SwapAboveDisplaySkip}
{\endalign}
\newenvironment{salign*}
{\par
\start@align\@ne\st@rredtrue\m@ne}
{\endalign}
\makeatother
\begin{document}

\section{Foo}
\begin{salign}
a^2+b^2 & = c^2
\end{salign}
\end{document}


I don't want to use this as then I need to define additional files so that the syntax highlighting for my editor works, which means the code won't be portable.

Replacing with renewenvironment creates a recursive loop, I've also tried \let\oldalign\align to fix this, but this doesn't compile.

• the whole point of the command is to manually use it in cases where the previous line is short, if you use it all the time it serves no purpose whatsoever you may as well just set \abovedisplayskip=\abovesdisplayshortskip so that you always get the smaller spacing Nov 16, 2019 at 2:33

You can have what you want with \AtBeginEnvironment from etoolbox and \useshortskip from nccmath (to be loaded before mathtools):

\documentclass{article}
\usepackage{nccmath, mathtools}
\usepackage{etoolbox}
\AtBeginEnvironment{align}{\useshortskip}
\AtBeginEnvironment{align*}{\useshortskip}
\begin{document}

\section{Foo}

\noindent\rule\textwidth{0.6pt}
\begin{align*}
a^2+b^2 & = c^2
\end{align*}
\noindent\rule\textwidth{0.6pt}
\begin{align}
a^2+b^2 & = c^2
\end{align}
\noindent\rule\textwidth{0.6pt}

\end{document}


Note: Of course, I tried the same code using \SwapAboveDisplaySkip first, but for some reason, I obtain an error message about a misplaced \noalign. Then I tried \useshortskip, which does essentially the same thing, and it worked.