It is the same question as How can I prevent wide equation having too large vertical space?, but the answers there don't address my case:
\documentclass[9pt]{beamer}
\usepackage[utf8]{inputenc}
\usefonttheme{serif}
\usepackage{tcolorbox}
\tcbuselibrary{magazine}
\tcbuselibrary{theorems}
\colorlet{greendark}{green!60!black}
\colorlet{bluelight}{blue!35!white}
\newtcbtheorem[number within=section]{mycomp}{Computation}%
{colframe=bluelight!60!greendark,enlarge top by=0.15cm,before
skip=3pt,after skip=6.5pt,fonttitle=\slshape,breakable}{comp}
\begin{document}
\begin{mycomp}{Mobius cancellation $G=\log \implies g = \frac 1t$}{mobiuscancellog}
$$\frac{1}{1/x} = x\sum_{d\leq x} \mu(d) \frac {-\log(\frac dx)}d + O\left(\sum_{d\leq x} \mu(d) (\tfrac{1}{d/x}+1))\right).$$
\end{mycomp}
\begin{mycomp}{Mobius cancellation $G=\log^2 \implies g = \frac {2\log t}{t}$}{mobiuscancellog2}
$$\frac{2 \log(\frac 1x)}{1/x} = x\sum_{d\leq x} \mu(d) \frac {-\log^2(\frac dx)}d + O\Big(\sum_{d\leq x} \mu(d) \left[\tfrac{\log(\frac dx)}{d/x}+1\right]\Big)$$
\end{mycomp}
\end{document}
Notice that the 2nd equation has more vertical space above the equation than below (compared distance from top of box to top of summation sign, and bottom of summation sign to bottom of box in both pictures).
I have determined that it must be solely based on width: by deleting enough of the 2nd equation, and it becomes shorter, it suddenly looks right again.
Can anyone suggest a fix?



$$in LaTeX document. No way, no how. Please read the posting Why is\[ ... \]preferable to$$ ... $$? for further information. – Mico Mar 05 '24 at 05:51professionalfontswith a custom font package, as long as it is not Computer Modern-based. So e.g.newtxdoesn't show the problem, butlmoderndoes. If you put an inner frame around the equation, you get more space, but it is balanced. Similarly if you insert an empty box after. (I used\[...\]for all tests. Using\centering$\displaystyle ...$also works, but obviously changes spacing. – cfr Mar 05 '24 at 06:02