# Too much space above align-environment if very little text prior to it

I am using the tcolorbox package for some boxes which often contain equations. If there is some text prior to the equation- or align-environment which is long enough to force the equation to be set down a bit, there is no problem in spacing. Both boxes have the same height (see first picture). But if there is not enough text above it, or no text at all, the equation-environment appears a bit further up, which is just right. But the align-environment does not behave like this, it has got too much space above it. That is why the two boxes differ in height (see second picture). This is my MWE, which creates the boxes shown in the pictures:

\documentclass[ngerman,a4paper,12pt]{scrbook}

\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsmath,amssymb}

\usepackage{tcolorbox}
\tcbuselibrary{skins}
\definecolor{maple-hblau}{RGB}{58,126,171}
\colorlet{colexample}{maple-hblau!75}
\newtcolorbox{examplebox}{%
empty,title={Example},attach boxed title to top left,
boxed title style={empty,size=minimal,toprule=2pt,top=4pt,overlay={\draw[colexample,line width=2pt] ([yshift=-1pt]frame.north west)--([yshift=-1pt]frame.north east);}},
coltitle=colexample,fonttitle=\footnotesize\bfseries,
before=\par\medskip\noindent,parbox=false,boxsep=0pt,left=0pt,right=3mm,top=4pt,
overlay={\draw[colexample,line width=1pt] ([yshift=-1pt]title.north east)--([xshift=-0.5pt,yshift=-1pt]title.north-|frame.east)--([xshift=-0.5pt]frame.south east)--(frame.south west); },
}

\begin{document}

\twocolumn

% long text prior to the align-environment -> no problem
\begin{examplebox}
Align*-Environment:
\begin{align*}
\frac{5}{2} = \frac{15}{6}
\end{align*}
\end{examplebox}

\newpage

% long text prior to the equation-environment, for comparison
\begin{examplebox}
Equation*-Environment:
\begin{equation*}
\frac{21}{9} = \frac{7}{3}
\end{equation*}
\end{examplebox}

\newpage

% not enough text prior to the align-environment -> too much white space above align
\begin{examplebox}
Align*:
\begin{align*}
\frac{5}{2} = \frac{15}{6}
\end{align*}
\end{examplebox}

\newpage

% the same amount of text prior to the equation-environment, for comparison
\begin{examplebox}
Equation*:
\begin{equation*}
\frac{21}{9} = \frac{7}{3}
\end{equation*}
\end{examplebox}

\end{document}


Is there a reason for the align-environment behaving like this or is this a bug?

And the more important question: How do I change this behavior of align, so that the box with the align-environment and just a bit text above it is as big as the box with the equation-environment besides it, so there is less space above the align-environment? Best would be to define this behavior globally, so I don't have to insert some command every time there is the align-environment and very little text above it.

• LaTeX's single-line equation environments -- equation and equation* -- use either \abovedisplayskip or \abovedisplayshortskip, depending on the length of the line that immediately precedes the environment. In contrast, the multiline equation environments of the amsmath package use only \abovedispkayskip. – Mico Aug 14 '17 at 0:14

This is a known problem: align doesn't use the shortskips.

The solution is to load the nccmath package, and to use the \useshortskip command before align:

\documentclass[ngerman,a4paper,12pt]{scrbook}

\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsmath,amssymb}
\usepackage{nccmath}

\usepackage{tcolorbox}
\tcbuselibrary{skins}
\definecolor{maple-hblau}{RGB}{58,126,171}
\colorlet{colexample}{maple-hblau!75}
\newtcolorbox{examplebox}{%
empty,title={Example},attach boxed title to top left,
boxed title style={empty,size=minimal,toprule=2pt,top=4pt,overlay={\draw[colexample,line width=2pt] ([yshift=-1pt]frame.north west)--([yshift=-1pt]frame.north east);}},
coltitle=colexample,fonttitle=\footnotesize\bfseries,
before=\par\medskip\noindent,parbox=false,boxsep=0pt,left=0pt,right=3mm,top=4pt,
overlay={\draw[colexample,line width=1pt] ([yshift=-1pt]title.north east)--([xshift=-0.5pt,yshift=-1pt]title.north-|frame.east)--([xshift=-0.5pt]frame.south east)--(frame.south west); },
}

\begin{document}

\twocolumn

% long text prior to the align-environment -> no problem
\begin{examplebox}
Align*-Environment:%\useshortskip
\begin{align*}
\frac{5}{2} = \frac{15}{6}
\end{align*}
\end{examplebox}

\newpage

% long text prior to the equation-environment, for comparison
\begin{examplebox}
Equation*-Environment:
\begin{equation*}
\frac{21}{9} = \frac{7}{3}
\end{equation*}
\end{examplebox}

\newpage

% not enough text prior to the align-environment -> too much white space above align
\begin{examplebox}
Align*:\useshortskip
\begin{align*}
\frac{5}{2} = \frac{15}{6}
\end{align*}
\end{examplebox}

\newpage

% the same amount of text prior to the equation-environment, for comparison
\begin{examplebox}
Equation*:
\begin{equation*}
\frac{21}{9} = \frac{7}{3}
\end{equation*}
\end{examplebox}

\end{document} • The solution is not to load the nccmath package but rather to use equation instead of align for single-line formulas. I would argue that align does not use the short skips by design. – Henri Menke Aug 14 '17 at 0:15
• You're right, but I suppose the O.P. meant he really needs to use a multilined equation. – Bernard Aug 14 '17 at 0:25
• Then there should also be a large skip around the equation. – Henri Menke Aug 14 '17 at 0:54
• "This is a known problem". I think this claim is too negative and too dismissive. The problem lies not in the amsmath package's multiline-math environments not using \abovedisplayshortskip and \belowdisplayshortskip. Instead, as Henri Menke has already pointed out, the real problem lies with those users who employ align and gather for single-line displayed equations despite the amsmath package providing numerous warnings not to do so. If anything, the authors of the amsmath package were guilty of having been too optimistic about users actually heeding such warnings. – Mico Aug 14 '17 at 5:22
• the failure of amsmath to use \abovedisplayshortskip for multi-line display environments has been on the bugs list for a very long time. the cause is the necessity of multi-line displays to measure the width in order to accommodate equation numbers; no account has been taken for the *ed version. i'm sure a good answer has been given for this already, but i'm unable to find it. – barbara beeton Aug 14 '17 at 13:07
{"ft_lang_label":"__label__en","ft_lang_prob":0.71297014,"math_prob":0.9351527,"size":3074,"snap":"2020-10-2020-16","text_gpt3_token_len":896,"char_repetition_ratio":0.15895766,"word_repetition_ratio":0.07821229,"special_character_ratio":0.24918672,"punctuation_ratio":0.12296564,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9949762,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-02-21T04:17:46Z\",\"WARC-Record-ID\":\"<urn:uuid:03106b5e-6ef0-4f02-bc2f-52ab91d7bb93>\",\"Content-Length\":\"150589\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:35676664-a377-49bd-8176-e70303b54630>\",\"WARC-Concurrent-To\":\"<urn:uuid:86691792-cd54-4ccc-a357-c1d128662f15>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://tex.stackexchange.com/questions/386258/too-much-space-above-align-environment-if-very-little-text-prior-to-it\",\"WARC-Payload-Digest\":\"sha1:2XXJXYFP3JMML6P5KL5CAEI5VIKAM6AK\",\"WARC-Block-Digest\":\"sha1:IXZ4I66ZL3RYXWM4OUBRBVODT4HLXZOX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-10/CC-MAIN-2020-10_segments_1581875145438.12_warc_CC-MAIN-20200221014826-20200221044826-00427.warc.gz\"}"}