如何改善表格行之间的垂直间距?

如何改善表格行之间的垂直间距?

我在以下帮助下创建了下表这个网络工具但我对行之间的垂直间距不满意。您能演示一下如何改进它并稍微减小表格的大小吗?使用该multirow命令是否方便?如果方便,如何实现?

\documentclass{article}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{csvsimple}
\usepackage{graphicx}

\sisetup{
    round-mode=places,
    uncertainty-mode = separate,
}

\begin{document}

\begin{table}[ht]
\centering
\caption{Summary of the \glspl{acronym:NEO} classification \cite{web:CNEOS:NEO:Basics:NEO:Groups}.}
\label{tab:NEOs:classification}
\begin{tabular}{@{}lll@{}}
\toprule
\multicolumn{1}{l}{\textbf{Group}} & \textbf{Definition} & \textbf{Description} \\ \midrule
NECs & \begin{tabular}[c]{@{}l@{}}$q \leq \SI{1.3}{\astronomicalunit}$ \\  $P  < \SI{200}{\years}$\end{tabular} & Near-Earth Comets \\[0.35cm]
NEAs & $q \leq \SI{1.3}{au}$ & Near-Earth Asteroids \\[0.35cm] 
Atiras & \begin{tabular}[c]{@{}l@{}}$a< \SI{1.0}{\astronomicalunit}$\\ $Q \leq \SI{0.983}{\astronomicalunit}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}\glspl{acronym:NEA} whose orbits are contained entirely with the\\ orbit of the Earth (named after asteroid 163693 Atira).\end{tabular} \\[0.35cm] 
Atens & \begin{tabular}[c]{@{}l@{}}$a< \SI{1.0}{\astronomicalunit}$\\ $Q > \SI{0.983}{\astronomicalunit} $\end{tabular} & \begin{tabular}[c]{@{}l@{}}Earth-crossing \glspl{acronym:NEA} with semi-major axes \\ smaller than Earth's (named after asteroid 2062 Aten).\end{tabular} \\[0.35cm]  
Apollos & \begin{tabular}[c]{@{}l@{}}$a> \SI{1.0}{\astronomicalunit}$\\ $q< \SI{1.017}{\astronomicalunit}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}Earth-crossing \glspl{acronym:NEA} with semi-major axes larger \\ than Earth's (named after asteroid 1862 Apollo).\end{tabular} \\[0.35cm]  
Amors & \begin{tabular}[c]{@{}l@{}}$a> \SI{1.0}{\astronomicalunit}$\\ $ 1.017 < q < 1.3 \SI{}{\astronomicalunit} $\end{tabular} & \begin{tabular}[c]{@{}l@{}}Earth-approaching \glspl{acronym:NEA} with orbits exterior to \\ Earth's but interior to Mars' (named after asteroid 1221 Amor).\end{tabular} \\[0.35cm] 
PHAs & \begin{tabular}[c]{@{}l@{}}$MOID \leq \SI{0.05}{\astronomicalunit}$\\ $H \leq \num{22.0}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}Potentially Hazardous Asteroids: \glspl{acronym:NEA} whose \\ \gls{acronym:MOID} with \\ the Earth is 0.05 au or less and whose absolute \\ magnitude ($H$) is 22.0 or brighter.\end{tabular} \\ \bottomrule
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

答案1

没有必要multirow

我会将最后一列定义为段落形式,并让 latex 决定换行。例如,我应用了m{<len>}固定长度和左对齐,因为您的示例是垂直居中的。

我认为最好使用它arraystretch来改变行间距。缺点是当因素较大时它会变得不对称,需要调整。在这种情况下,只有第一行需要额外的支柱(通过\rule...)。

我还创建了一个方便的宏来添加多行arraystretch定义为 1 的行,因此内部行间距保持默认 - 当然,这可能会发生变化。

以下是表格

在此处输入图片描述

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{ragged2e}
% \usepackage{csvsimple}
% \usepackage{graphicx}

\sisetup{
    round-mode=places,
    uncertainty-mode = separate,
}
\DeclareSIUnit\years{Y}    % \years is not defined 
\newcommand\glspl[1]{#1}   % Here: error compiling the code, hence this macro
\newcommand\gls[1]{#1}     % Here: error compiling the code, hence this macro
\NewDocumentCommand\TB{O{l}m}{%
    \renewcommand\arraystretch{1}
    \begin{tabular}{@{}#1@{}}#2\end{tabular}}


\begin{document}
\begin{table}[ht]
    \renewcommand\arraystretch{1.85}
    \centering
    \caption{Summary of the \protect\glspl{acronym:NEO} classification \cite{web:CNEOS:NEO:Basics:NEO:Groups}.}
    \label{tab:NEOs:classification}
    \begin{tabular}{@{}ll >{\RaggedRight}m{8cm}@{}}
        \toprule
        \rule[-0.7\normalbaselineskip]{0pt}{1.8\normalbaselineskip}%
        \textbf{Group}
        & \textbf{Definition}
        & \textbf{Description}\\
        \midrule
        NECs
        & \TB{
            $q\leq \qty{1.3}{\astronomicalunit}$\\
            $P < \qty{200}{\years}$
        }
        & Near-Earth Comets \\
        NEAs
        & $q \leq \qty{1.3}{au}$
        & Near-Earth Asteroids \\
        Atiras
        & \TB{
            $a< \qty{1.0}{\astronomicalunit}$\\
            $Q \leq \qty{0.983}{\astronomicalunit}$
        }
        & \glspl{acronym:NEA} whose orbits are contained entirely with the orbit of the Earth (named after asteroid 163693 Atira). \\
        Atens
        & \TB{
            $a< \qty{1.0}{\astronomicalunit}$\\
            $Q > \qty{0.983}{\astronomicalunit} $
        } 
        & Earth-crossing \glspl{acronym:NEA} with semi-major axes smaller than Earth's (named after asteroid 2062 Aten). \\
        Apollos
        & \TB{
            $a> \qty{1.0}{\astronomicalunit}$\\
            $q< \qty{1.017}{\astronomicalunit}$
        }
        & Earth-crossing \glspl{acronym:NEA} with semi-major axes larger than Earth's (named after asteroid 1862 Apollo). \\ 
        Amors
        & \TB{
            $a> \qty{1.0}{\astronomicalunit}$\\
            $1.017 < q < 1.3 \qty{}{\astronomicalunit}$}
        & Earth-approaching \glspl{acronym:NEA} with orbits exterior to Earth's but interior to Mars' (named after asteroid 1221 Amor). \\
        PHAs
        & \TB{%
            $MOID \leq \qty{0.05}{\astronomicalunit}$\\
            $H \leq \num{22.0}$
        }
        & Potentially Hazardous Asteroids: \glspl{acronym:NEA} whose \gls{acronym:MOID} with the Earth is 0.05 au or less and whose absolute magnitude ($H$) is 22.0 or brighter. \\
        \bottomrule
    \end{tabular}
\end{table}
\end{document}

另一个解决方案是tabularx使用X-column-type 来避免必须搜索准确的列宽。默认情况下,tabularx定义Xp{},但在上表中它可能不起作用。tabularxcolumn提供宏:来重新定义X,例如

\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight}m{#1}}

答案2

我将使用\tblrtabularray并重新定义\TB样式:

\documentclass{article}
\usepackage{caption}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\sisetup{
    round-mode=places,
    uncertainty-mode = separate,
}
\DeclareSIUnit\years{Y}    % \years is not defined
\newcommand\glspl[1]{#1}   % Here: error compiling the code, hence this macro
\newcommand\gls[1]{#1}     % Here: error compiling the code, hence this macro
\NewDocumentCommand\TB{m}{\begin{array}{@{}l @{}}#1\end{array}}

\begin{document}
    \begin{table}[ht]
    \centering
\caption{Summary of the \protect\glspl{acronym:NEO} classification \cite{web:CNEOS:NEO:Basics:NEO:Groups}.}
\label{tab:NEOs:classification}
    \begin{tblr}{colspec={@{} l Q[l, mode=math] X[l,m] @{}},
                 row{1} ={font=\bfseries, mode=text}
                 }
        \toprule
Group   &   Definition  
            & Description                           \\
        \midrule
NECs    & \TB{q\leq \qty{1.3}{au}\\
              P < \qty{200}{\years}}
            & Near-Earth Comets                     \\
NEAs    &   q \leq \qty{1.3}{au} 
            & Near-Earth Asteroids                  \\
Atiras  & \TB{a <    \qty{1.0}{au}   \\
              Q \leq \qty{0.983}{au}}
            & \glspl{acronym:NEA} whose orbits are contained entirely with the orbit of the Earth (named after asteroid 163693 Atira).                          \\
Atens   & \TB{a < \qty{1.0}{\astronomicalunit}  \\
              Q > \qty{0.983}{\astronomicalunit}}
        & Earth-crossing \glspl{acronym:NEA} with semi-major axes smaller than Earth's 
        (named after asteroid 2062 Aten).           \\
Apollos & \TB{a> \qty{1.0}{\astronomicalunit}   \\
              q< \qty{1.017}{\astronomicalunit}}
        & Earth-crossing \glspl{acronym:NEA} with semi-major axes larger than Earth's 
        (named after asteroid 1862 Apollo).         \\
Amors   & \TB{a> \qty{1.0}{\astronomicalunit}   \\
              1.017 < q < 1.3 \qty{}{\astronomicalunit}}
        & Earth-approaching \glspl{acronym:NEA} with orbits exterior to Earth's but interior to Mars' (named after asteroid 1221 Amor). \\
PHAs    & \TB{MOID \leq \qty{0.05}{\astronomicalunit} \\
              H \leq \num{22.0}}
        & Potentially Hazardous Asteroids: \glspl{acronym:NEA} whose \gls{acronym:MOID} with the Earth is 0.05 au or less and whose absolute magnitude ($H$) is 22.0 or brighter. \\
    \bottomrule
    \end{tblr}
    \end{table}
\end{document}

在此处输入图片描述

答案3

\\[0.35cm]每行末尾的代码都会给出一个间距为 3.5 毫米的换行符。您可以减少该数字 - 甚至删除整个括号。:)

相关内容