如何调整表格的列宽

如何调整表格的列宽

我在以下代码中有一个表格:

\documentclass{revtex4-1}

\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{bm}
\usepackage{tabularx}

\begin{document}
\begin{table*}
  \footnotesize
  \caption{\label{tab:dimensionlessnumber}
  Definitions and physical meanings of dimensionless quantities.}
  \begin{ruledtabular}
  \begin{tabularx}{\textwidth}{llX}
  \textrm{number group} & \textrm{Definition} & \textrm{Physical meaning}  \\
  \colrule
  Density ratio               & $D=\frac{\rho_1}{\rho_2}$
  & A measure of the ratio of the A to B densities            \\
  Reactive number             & $R=\frac{s\Delta p}{a b C}$
  & The ratio of two very different quantities, a measure of the rate of reaction (very complicated), different from another definition in the reference                         \\
  Non-dimensional non-trivial parameter & $N=bk/aC$
  & A measure of the non-trivial degree at another side       \\
  \end{tabularx}
  \end{ruledtabular}
\end{table*}

\end{document}

它给

在此处输入图片描述

在此表中,

  1. 第三列第二行无法完全显示。有没有办法自动将较长的条目拆分为具有适当列宽的多行,以便宽度超过列宽的文本将放在新行上?

  2. 第一列的第三行明显比其他行长。我试图\\将其换行。但这样一来,第二列的条目(例如 的定义$N$)就会跟在第二行后面,见下图。相反,我希望它在第一行。

为了解决这个问题,我使用了tabularx环境(将宽度设置为\textwidth,如下图所示这个问题另一个问题。我甚至还\footnotesize缩小了表格的字体。但问题仍然存在。感谢您的任何建议!

在此处输入图片描述

答案1

删除ruledtabular并使用p第一列的 type。另外,为了让表格更易读,您可以将行距增加。最后,您可以考虑使用\renewcommand{\arraystretch}{1.5}而不是多个s来获得更好的输出。\hlinebooktabs

\documentclass{revtex4-1}

\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{bm}
\usepackage{tabularx}

\begin{document}
\begin{table*}
  \renewcommand{\arraystretch}{1.5}
  \caption{\label{tab:dimensionlessnumber}
  Definitions and physical meanings of dimensionless quantities.}
  %\begin{ruledtabular}
  \begin{tabularx}{\textwidth}{ >{\raggedright}p{10em} l X }
  \hline \hline
  \textrm{number group} & \textrm{Definition} & \textrm{Physical meaning}  \\
  \hline
  Density ratio               & $D=\frac{\rho_1}{\rho_2}$
  & A measure of the ratio of the A to B densities            \\
  Reactive number             & $R=\frac{s\Delta p}{a b C}$
  & The ratio of two very different quantities, a measure of the rate of reaction (very complicated), different from another definition in the reference                         \\
  Non-dimensional non-trivial parameter & $N=bk/aC$
  & A measure of the non-trivial degree at another side       \\ \hline\hline
  \end{tabularx}
  %\end{ruledtabular}
\end{table*}

\end{document}

在此处输入图片描述

答案2

不错的变体阿博阿马尔回答:

  • \makegapedcells通过使用包中的宏可以获得表格行之间的更多空间makecell
  • 顶部和底部的水平线被替换为Xhline{0.8pt}
  • 方程式为\displaystale

\documentclass{revtex4-1}

\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{amssymb}
%\usepackage{amsfonts}
\usepackage{bm}
\usepackage{makecell, tabularx}
\setcellgapes{4pt}

\begin{document}
\begin{table*}
\makegapedcells
    \caption{Definitions and physical meanings of dimensionless quantities.}
\label{tab:dimensionlessnumber}
\begin{tabularx}{\textwidth}{ >{\raggedright}p{10em}
                            >{$\displaystyle}l<{$}
                            X }
\Xhline{0.8pt}
number group    &   \text{Definition}   &   Physical meaning    \\
\hline
Density ratio   & D=\frac{\rho_1}{\rho_2}
    &   A measure of the ratio of the A to B densities          \\
Reactive number & R=\frac{s\Delta p}{a b C}
    &   The ratio of two very different quantities, a measure of the rate of reaction (very complicated), different from another definition in the reference                                               \\
Non-dimensional non-trivial parameter
                & N=\frac{bk}{aC}
    &   A measure of the non-trivial degree at another side     \\
\Xhline{0.8pt}
\end{tabularx}
\end{table*}

\end{document}

在此处输入图片描述

答案3

我发现这里给出了最好的解决方案: https://www.overleaf.com/learn/latex/Questions/How_do_I_change_column_or_row_separation_in_LaTeX_tables%3F

\renewcommand{\arraystretch}{2}
\setlength{\tabcolsep}{10pt}

它们分别增加了列宽和行宽。尽情享用吧!

相关内容