So I know of the fact that you should never begin a paragraph with display math if you want to avoid that weird space above your math. But in my case I have a box, and inside that box I want my equations to be aligned. And align* is display math. And as my box is for equations only, I do not have text above that display math. Hence the vertical space.
How do I align my equations – that are not supposed to be surrounded by text – without having an annoying vertical space above?
\documentclass[a5paper,12pt,dvipsnames,twoside,openany]{memoir}
\usepackage[a5paper]{geometry}
\usepackage[dvipnames,table]{xcolor}
\usepackage[many]{tcolorbox}
\usepackage{tikz}
\usepackage{bm,amsmath,amssymb,amsthm,gensymb,esdiff,siunitx}
\usetikzlibrary{tikzmark,fit,shadows}
\tikzset{highlight/.style args={#1}{fill=#1,
rounded corners=1.6pt,
inner xsep=1ex,
minimum height=1.5em}}
\tcbset{enhanced,
boxrule=0.8pt,
bottomrule=1.6pt,
arc=1pt,
auto outer arc,
lifted shadow={1mm}{-1mm}{2mm}{0.1mm}{gray!60}}
\colorlet{backLightYellow}{red!30!yellow!30!white!30}
\colorlet{framLightYellow}{black!30!yellow!30}
\colorlet{backDarkYellow}{black!30!red!30!yellow}
\colorlet{framDarkYellow}{red!30!yellow!40}
\def \epc {6.241 509 074 460 76 E18}
\def \cpe {1.602 176 634 E-19}
\begin{document}
\begin{tcolorbox}[colback=backLightYellow,colframe=framLightYellow]\small
\begin{tikzpicture}[overlay,remember picture]
\iftikzmark{lhs1}{%
\node[yshift=3pt,fit=(pic cs:lhs1)(pic cs:rhs1),highlight={backDarkYellow},yshift=-.8pt]{};%
\node[yshift=3pt,fit=(pic cs:lhs1)(pic cs:rhs1),highlight={framDarkYellow}]{};%
}{\typeout{Please recompile.}}
\iftikzmark{lhs2}{%
\node[yshift=3pt,fit=(pic cs:lhs2)(pic cs:rhs2),highlight={backDarkYellow},yshift=-.8pt]{};%
\node[yshift=3pt,fit=(pic cs:lhs2)(pic cs:rhs2),highlight={framDarkYellow}]{};%
}{\typeout{Please recompile.}}
\end{tikzpicture}
\begin{align*}
\tikzmark{lhs1}\SI{\cpe}{\coulomb}
&= \SI{1}{\elementarycharge}\tikzmark{rhs1}\\
\frac{\SI{\cpe}{\coulomb}}{\num{\cpe}}
&= \frac{\SI{1}{\elementarycharge}}{\num{\cpe}}\\
\tikzmark{lhs2}\SI{1}{\coulomb}
&= \SI{\epc}{\elementarycharge}\tikzmark{rhs2}
\end{align*}
\end{tcolorbox}
\end{document}
{aligned}(in math mode) instead of{align*}. – F. Pantigny Feb 12 '20 at 20:30\vspace{-\baselineskip}to hide the blank line. The remaining margins are from tcolorbox and have nothing to do with align. – John Kormylo Feb 12 '20 at 21:02