最后一行和底部规则之间的间距太大。为什么会发生这种情况?我该如何删除这些空间?
我的源代码:
\documentclass{report}
\usepackage{amsmath,array,booktabs,multirow}
\usepackage{ragged2e}
\usepackage{tabularx}
\usepackage{makecell}
\newcolumntype{C}{ >{ \arraybackslash \Centering } X }
\renewcommand \tabularxcolumn [1] { >{ \centering } m{#1} }
\newcommand {\scalelinespace} [1] {\rule{0pt}{#1\normalbaselineskip}}
\begin{document}
\begin{table}[h]
\centering
\begin{tabularx}{1\textwidth}[h]{>{\hsize=0.5\hsize}C| >{\hsize=1.7\hsize}C| >{\hsize=1\hsize}CC|}
\toprule
\textbf{Name} & \textbf{Math} & \textbf{More Math} \\
\midrule
Foo &
$\begin{aligned}
A &= x^{2} + y^{3} \\[-1.5mm]
BC &= x^{3} - y^{2}
\end{aligned}$
&
$\begin{aligned}
x &\leftarrow x \thinspace (1 - \alpha) \\[-1.5mm]
y &\leftarrow y \thinspace (1 + \beta)
\end{aligned}$
\\
\Xcline{3-3}{0.2mm}
Bar &
\hspace{4.1mm} $D = x y + w_{z}$
\text{Note if } $A>D \text{ then } D \leftarrow AB+C$
&
$w_{z} \leftarrow w_{z} \thinspace (1 + q)$
\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案1
请注意,不建议将垂直线与包装一起使用
booktabs
,例如查看线条周围的所有间隙......
如果删除一些不必要的空行,多余的空间就会消失:
\documentclass{report}
\usepackage{amsmath,array,booktabs,multirow}
\usepackage{ragged2e}
\usepackage{tabularx}
\usepackage{makecell}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}[h]
\centering
\begin{tabularx}{\textwidth}[h]{l|C|l}
\toprule
\textbf{Name} & \textbf{Math} & \textbf{More Math}\\
\midrule
Foo & $\begin{aligned}
A &= x^{2} + y^{3} \\[-1.5mm]
BC &= x^{3} - y^{2}
\end{aligned}$
& $\begin{aligned}
x &\leftarrow x \thinspace (1 - \alpha) \\[-1.5mm]
y &\leftarrow y \thinspace (1 + \beta)
\end{aligned}$\\
\cmidrule{3-3}
Bar &
\makecell[c]{$D = x y + w_{z}$ \\
\text{Note if } $A>D \text{ then } D \leftarrow AB+C$} &
$w_{z} \leftarrow w_{z} \thinspace (1 + q)$\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
(我删除了手动调整列宽的做法,否则使用tabularx
就没有意义了,正常的表格宽度固定宽度会更好)