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.
Best Answer
This is a known problem:
align
doesn't use the shortskips.The solution is to load the
nccmath
package (part ofncctools
), and to use the\useshortskip
command beforealign
: