![对齐上方的垂直空间(未被文本包围)](https://linux22.com/image/408010/%E5%AF%B9%E9%BD%90%E4%B8%8A%E6%96%B9%E7%9A%84%E5%9E%82%E7%9B%B4%E7%A9%BA%E9%97%B4%EF%BC%88%E6%9C%AA%E8%A2%AB%E6%96%87%E6%9C%AC%E5%8C%85%E5%9B%B4%EF%BC%89.png)
所以我知道,如果你想避免数学上方出现奇怪的空白,就永远不应该用显示数学来开始一个段落。但在我的例子中,我有一个框,我希望我的方程式在框内对齐。并且align*
是显示数学。由于我的框仅用于方程式,因此在显示数学上方没有文本。因此有垂直空间。
我该如何对齐我的方程式(它们不应该被文本包围),而不在上面留下恼人的垂直空间?
\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}