在下表中,我\\
在开头添加了一个空格,这样变量之间就可以互相留出空间,但是现在出现了这个间隙——列中行与行之间没有边框,而这在最初是存在的——如屏幕截图所示——我该如何再次消除这些间隙?非常感谢
代码是:
% Uncomment the following line to allow the usage of graphics (.png, .jpg)
%\usepackage[pdftex]{graphicx}
% Comment the following line to NOT allow the usage of umlauts
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{amsmath}
% Start the document
\begin{document}
\begin{table}
\centering % Centre the table on the slide
\begin{tabular}{|c|c|c|c|}
\toprule
Name & Equation & Description & Variables\\
\toprule
Reynolds & $Re=\frac{g}{g}$ & desc & \shortstack{$\mu$- dynamic viscosity \\ v- velocity \\ L \\ $\rho $- density }\\
\\ Ohnesorge & $Oh=\frac{f}{g}$ & $\rho$ & \shortstack{$\mu$ \\ $\sigma$- surface-tension coefficient \\ L \\ $\rho$ }\\
\\ Weber & We & $\frac{ff}{ff}$ & \shortstack{$\nu$ \\ $\sigma$ \\ L \\ $\rho$ }\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
我会像这样写你的表格:
\documentclass{article}
\usepackage{booktabs, makecell}
\usepackage{amsmath}
\begin{document}
\begin{table}
\centering % Centre the table on the slide
\linespread{0.84}\selectfont
\begin{tabular}{lccl}
\toprule
Name & Equation & Description & Variables\\
\midrule
Reynolds & $Re=\frac{g}{g}$ & desc & \makecell[l]{$\mu$: dynamic viscosity \\
$v$: velocity \\
L \\
$\rho$: density }\\
\addlinespace[6pt]
Ohnesorge & $Oh=\frac{f}{g}$ & $\rho$ & \makecell[l]{$\mu$: dynamic viscosity \\
$v$: velocity \\
L \\
$\rho$: density }\\
\addlinespace[6pt]
Weber & We & $\frac{ff}{ff}$ & \makecell[l]{$\nu$ \\
$\sigma$ \\
L \\
$\rho$ }\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
就像@Zarko 的回答,我会取消所有垂直线——相信我,它们没有必要,而且不会被忽略。我还会让单元格内容左对齐,让单元格内容在行间上对齐,用 替换第二条指令\toprule
,\midrule
用更省事的 替换所有空白行\addlinespace
。
\documentclass{article}
\usepackage[utf8]{inputenc} % this is the default nowadays
\usepackage[T1]{fontenc}
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule, and \addlinespace macros
\usepackage{amsmath} % for \smash[b] macro
% Start the document
\begin{document}
\begin{table}
\centering % Centre the table horizontally
\begin{tabular}{@{} llll @{}} % suggestion: use 'l', not 'c', col. type
\toprule
Name & Equation & Description & Variables\\
\midrule
Reynolds & $\mathit{Re}=\smash[b]{\frac{g}{g}}$ & desc
& $\mu$ -- dynamic viscosity \\
&&& $v$ -- velocity \\
&&& $L$ \\
&&& $\rho$ -- density \\
\addlinespace % <-- new
Ohnesorge & $\mathit{Oh}=\smash{\frac{f}{g}}$ & $\rho$
& $\mu$ \\
&&& $\sigma$ -- surface-tension coeff. \\
&&& $L$ \\
&&& $\rho$ \\
\addlinespace % <-- new
Weber & $\mathit{We}$ & $\smash{\frac{ff}{ff}}$
& $\nu$ \\
&&& $\sigma$ \\
&&& $L$ \\
&&& $\rho$ \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案3
如果您实际上想要垂直规则与 的水平规则兼容booktabs
(即使它完全不符合 的精神booktabs
),您可以{NiceTabular}
使用nicematrix
。
\documentclass{article}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage{makecell}
\usepackage{amsmath}
% Start the document
\begin{document}
\begin{table}
\centering % Centre the table on the slide
\begin{NiceTabular}{|c|c|c|c|}
\toprule
Name & Equation & Description & Variables\\
\toprule
Reynolds & $Re=\frac{g}{g}$ & desc & \shortstack{$\mu$- dynamic viscosity \\ v- velocity \\ L \\ $\rho $- density }\\
\\ Ohnesorge & $Oh=\frac{f}{g}$ & $\rho$ & \shortstack{$\mu$ \\ $\sigma$- surface-tension coefficient \\ L \\ $\rho$ }\\
\\ Weber & We & $\frac{ff}{ff}$ & \shortstack{$\nu$ \\ $\sigma$ \\ L \\ $\rho$ }\\
\bottomrule
\end{NiceTabular}
\end{table}
\end{document}
booktabs
我建议按照其他人的答案中描述的精神进行设计。