减少乳胶表中两行之间的间距

减少乳胶表中两行之间的间距

我正在用 latex 写一个表,其中一个条目(算法名称)太大。我将其内容分为三行,如下表所示:

\begin{tabular}{lccc}
    \toprule
    \textbf{Problem} & \multicolumn{3}{c}{\textbf{Mean objective value}} \\
    \midrule
    & Algorithm X & \scriptsize  Algorithm X without &  Algorithm X with \\
    &             & \scriptsize component A and with &  component C \\
    &             & \scriptsize and component B      & \\
    \midrule
    eil51         & \textbf{427.267} & \underline{1286.37} & 439.467 \\
    \bottomrule
\end{tabular}

但是,编译为 pdf 时这些线条分离得太远了。

在此处输入图片描述

是否可以减少两个表格行之间的间距?还有其他解决方案吗?

可能的解决方案:

  • 我尝试过\renewcommand{\baselinestretch}{2},但没有效果。

答案1

我会在标题的主要条目下方添加条款:

\documentclass{article}

\usepackage{booktabs}

\newcommand{\descrcell}[2]{%
  \scriptsize
  \begin{tabular}[t]{@{}c@{}}\normalsize#1\\#2\end{tabular}%
}


\begin{document}
\begin{tabular}{lccc}
\toprule
\textbf{Problem} & \multicolumn{3}{c}{\textbf{Mean objective value}} \\
\midrule
& Algorithm X
& \descrcell{Algorithm X}{without component A \\ and with component B}
& \descrcell{Algorithm X}{with component C} \\
\midrule
eil51         & \textbf{427.267} & \underline{1286.37} & 439.467 \\
\bottomrule
\end{tabular}

\end{document}

在此处输入图片描述

答案2

如果使用\addlinespace该包,则可以减小或增大行距:booktabs

\documentclass{article}

\usepackage{booktabs}
\begin{document}
Without \verb!\addlinespace!

\begin{tabular}{lccc}
    \toprule
    \textbf{Problem} & \multicolumn{3}{c}{\textbf{Mean objective value}} \\
    \midrule
    & Algorithm X & \scriptsize  Algorithm X without &  Algorithm X with \\
    &             & \scriptsize component A and with &  component C \\
    &             & \scriptsize and component B      & \\
    \midrule
    eil51         & \textbf{427.267} & \underline{1286.37} & 439.467 \\
    \bottomrule
\end{tabular}

With \verb!\addlinespace!

\begin{tabular}{l*{3}c}    
    \toprule
    \textbf{Problem} & \multicolumn{3}{c}{\textbf{Mean objective value}} \\
    \midrule
    & Algorithm X & \scriptsize  Algorithm X without &  Algorithm X with \\
    \addlinespace[-0.3ex]
    &             & \scriptsize component A and with &  component C \\
    \addlinespace[-0.4ex]
    &             & \scriptsize and component B      & \\
    \midrule
    eil51         & \textbf{427.267} & \underline{1286.37} & 439.467 \\
    \bottomrule


\end{tabular}

\end{document}

在此处输入图片描述

相关内容