减少表格中多行描述的行间空间

减少表格中多行描述的行间空间

我需要

a) 减少多行描述的行间空间。

b) 能够控制列的宽度,使表格看起来更好。对于当前表格,我希望列之间的空间稍微宽一些。

\documentclass[preprint,12pt]{elsarticle}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\interdisplaylinepenalty=2500
\usepackage{indentfirst}
\usepackage{tabularx}  
\usepackage{ragged2e} 
\usepackage{tikz}
\usepackage{booktabs}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X} 


\begin{document}

\begin{table}[h] %htbp
\caption{Nomenclature} 
\label{tab:des_vars}
\begin{tabularx}{\textwidth}{@{}l l Y@{}} 
\toprule
Notation & Supporting set & Description \\
\midrule
\hline
$y_{ijk}$ & $\{0, 1\}$ & 1 if there exists edge $(i, j)$\\
& & using the type $k$\\
\addlinespace
$a_{ij}$ & $\mathbb{R}^{+}$ & non-negative volume that\\
& & passes quickly through $(i, j)$  \\   
& & very very very very long description follows  \\ 
\addlinespace
\bottomrule
\end{tabularx}
\end{table}

\end{document} 

答案1

除了摆脱大多数指令之外,您还应该利用列类型允许在单元格内自动换行\addlinespace这一事实。Y

在此处输入图片描述

\documentclass[12pt]{elsarticle}
\usepackage{amsmath}
%%\usepackage{amsfonts} % 'amsfonts' is loaded automatically by 'amssymb'
\usepackage{amssymb}
%%\interdisplaylinepenalty=2500 % really?
\usepackage{indentfirst}
\usepackage{tabularx,ragged2e} 
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X} 

%\usepackage{tikz} % not needed for this example
\usepackage{booktabs}

\begin{document}

\begin{table}[htbp]
\caption{Nomenclature} 
\label{tab:des_vars}

\smallskip
\footnotesize % <-- optional
\begin{tabularx}{\textwidth}{@{} l l Y @{}} 
\toprule
Notation & Supporting set & Description \\
\midrule
$y_{ijk}$ & $\{0,1\}$ & $1$ if there exists edge $(i,j)$ using the type~$k$  \\
\addlinespace
$a_{ij}$ & $\mathbb{R}^{+}$ & Non-negative volume that passes quickly through $(i,j)$. \\
& & Very very very very long description follows.  \\   
\bottomrule
\end{tabularx}
\end{table}

\end{document}

答案2

正如@campa在他的评论中提到的那样,您可以手动在行之间插入额外的空间。 不过,我会按照以下方式编写您的表格:

\documentclass[preprint,12pt]{elsarticle}
\usepackage{amsmath, amssymb}
\interdisplaylinepenalty=2500
\usepackage{ragged2e}
\usepackage{tabularx}
\usepackage{booktabs}
\newcolumntype{R}{>{\RaggedRight}X}


\begin{document}
    \begin{table}[ht] %htbp
\caption{Nomenclature}
\label{tab:des_vars}
    \begin{tabularx}{\textwidth}{@{}l l R @{}}
    \toprule
Notation & Supporting set & Description \\
    \midrule
$y_{ijk}$ & $\{0, 1\}$ & 1 if there exists edge $(i, j)$ using the type $k$\\
    \addlinespace
$a_{ij}$ & $\mathbb{R}^{+}$ & non-negative volume that passes quickly through $(i, j)$  
                             very very very very long description follows\\
    \bottomrule
\end{tabularx}
    \end{table}
\end{document} 

在此处输入图片描述

编辑: 现在被视为已编辑的问题。顺便说一句,X从中派生的列类型会自动拆分长行。这显示在第二个表格行中,因此您无需在表格行之间手动拆分长文本...

附录:
您可以考虑使用tabularray包来编写表格。好处:更灵活,代码更短;

\documentclass[preprint,12pt]{elsarticle}
\usepackage{amsmath, amssymb}
\interdisplaylinepenalty=2500
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\usepackage[skip=1ex]{caption}


\begin{document}
    \begin{table}[ht]  
\caption{Nomenclature}
\label{tab:des_vars}
    \begin{tblr}{colsep=9pt,
                 colspec = {@{} Q[l, mode=math] 
                                Q[l, mode=math] X[l, cmd={\RaggedRight\hspace{0pt}}] @{}},
                 row{1}  = {mode=text},
                 row{2-Y}= {rowsep=5pt}
                 }
    \toprule
Notation & Supporting set & Description \\
    \midrule
y_{ijk} & \{0, 1\}  & 1 if there exists edge $(i, j)$ using the type $k$    \\
a_{ij}  & \mathbb{R}^{+} 
                    & non-negative volume that passes quickly through $(i, j)$  
                    very very very very long description follows    \\
    \bottomrule
\end{tblr}
    \end{table}
\end{document} 

在此处输入图片描述

相关内容