![在表格环境中使用案例时删除多余的垂直空间](https://linux22.com/image/462219/%E5%9C%A8%E8%A1%A8%E6%A0%BC%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8%E6%A1%88%E4%BE%8B%E6%97%B6%E5%88%A0%E9%99%A4%E5%A4%9A%E4%BD%99%E7%9A%84%E5%9E%82%E7%9B%B4%E7%A9%BA%E9%97%B4.png)
我有一张表,cases
其中有一列如建议的那样这里。我面临的问题是第一列有一些文本,并且使用cases
在第一列的文本内留下一个空白。我尝试了建议的解决方案这里,但这并不能解决问题。有没有办法让第二列的案例与第一列的文本水平对齐。还可以删除案例行和下一行之间的垂直空间。
平均能量损失
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{p{5.5cm}p{5cm}}
Velocity of light in vacuum & $c = \SI{2.998d8}{\meter\per\second}$\\
Gravitational constant & \[ G = \begin{cases} \SI{6.67d-11}{\meter\cubed\per\kilo\gram\per\second\squared} \\
\SI{6.67d-8}{\centi\meter\cubed\per\gram\per\second\squared}\end{cases} \] \\
Acceleration of free fall & $ g = \SI{9.807}{\meter\per\second\squared}$ \\\end{tabular}
\end{document}
答案1
像这样:
- 正如@Οὖτις 提到的,数学应该是内联的
- 无关:
- 您使用的是旧版本(版本 2)
siunitx
sintay。我建议使用新版本,由软件包版本 3 引入(请参阅下面的 MWE) tabularray
通过使用包可以获得更简单的表格代码
- 您使用的是旧版本(版本 2)
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{amsmath,
booktabs,
siunitx}
\begin{document}
\noindent\begin{tblr}{colspec = {l X[l, mode=math]},
rowsep=3pt} % 5pt. pw desired bigger vertical distance between math terms
Velocity of light in vacuum
& c = \SI{2.998d8}{\meter\per\second} \\
Gravitational constant
& G = \begin{cases}
\qty{6.67e-11}{\meter\cubed\per\kilo\gram\per\second\squared} \\
\qty{6.67e-8}{\cm\cubed\per\gram\per\second\squared}
\end{cases} \\
Acceleration of free fall
& g = \qty{9.807}{\meter\per\second\squared} \\
\end{tblr}
\end{document}
答案2
这是可能的nicematrix
\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{nicematrix}
\newcolumntype{e}{@{$\mspace{\thickmuskip}$}c@{$\mspace{\thickmuskip}$}}
\begin{document}
\begin{equation*}
\everymath{\displaystyle}
\begin{NiceArray}[cell-space-limits=1.1pt]{p[l]{5.5cm} r e l}
\text{Velocity of light in vacuum}
& c
& =
& \SI{2.998d8}{\meter\per\second}
\\
\text{Gravitational constant}
& G
& =
&
\begin{cases}
\SI{6.67d-11}{\meter\cubed\per\kilo\gram\per\second\squared} \\
\SI{6.67d-8}{\centi\meter\cubed\per\gram\per\second\squared}
\end{cases}
\\
\text{Acceleration of free fall}
& g
& =
& \SI{9.807}{\meter\per\second\squared}
\end{NiceArray}
\end{equation*}
\end{document}