我有如下所示的表格。由于第 2 行的标题很长,数字及其百分比彼此相距甚远,导致表格难以阅读。
问:如何减少包含数字和百分比的列之间的空间,以使距离变得合理,并使数字和其百分比彼此接近。
我在另一个表中使用了较短的标题,但问题并未出现,而且看起来不错。我希望上面的大表在数字和百分比之间的列间距方面看起来像这样。
请注意,我需要将数字与百分比分开,因为对齐问题否则无法解决。
以下是示例脚本:
\documentclass[10pt]{llncs}
\usepackage{graphicx}
\usepackage{sistyle}
\SIthousandsep{,}
\usepackage{booktabs}
\usepackage{array, makecell}
\usepackage{adjustbox}
\begin{document}
\title{Test}
\maketitle
\begin{table}[!tp]
\centering
\caption{Table}
\begin{tabular}{lrrrrrr}
\toprule
& \multicolumn{6}{c}{\thead{Title}} \\
\cline{2-7}
& \multicolumn{2}{r}{\texttt{Col\#1 title starts here}} & \multicolumn{2}{r}{\texttt{Col\#2 title starts here}} & \multicolumn{2}{r}{\texttt{Col\#3 title starts here}} \\
\midrule
Title \#1
& \multicolumn{2}{r}{\num{44444}} & \multicolumn{2}{r}{\num{222222}} & \multicolumn{2}{r}{\num{1111111}} \\
\midrule
\quad Title\#2 is Here
& \num{44444}&(99.99\%) & \num{222222}&(99.99\%) & \num{1111111}&(99.99\%) \\
\midrule
\quad \quad Title\#3 is Here (brackets)
& \num{44444}&(99.99\%) & \num{222222}&(99.99\%) & \num{1111111}&(99.99\%)\\
\quad \quad \quad Title \#4 is Here
& \num{33333}&(77.77\%) & \num{666666}&(22.22\%) & \num{1111111}&(111\%) \\
\quad \quad \quad \quad \% Title\#4 is Here
& \num{77}&(2.22\%) & \num{361}&(0.59\%) & \num{444444}&(33.33\%) \\
\bottomrule
\end{tabular}
\vspace{-10pt}
\end{table}
\end{document}
答案1
您需要允许换行。一种方法是使用tabularx
环境。
\documentclass[10pt]{llncs}
\usepackage{sistyle}
\SIthousandsep{,}
\usepackage{booktabs}
\usepackage{tabularx, ragged2e, makecell}
\newcolumntype{R}{>{\RaggedLeft\arraybackslash}X}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcommand\myhsize{\dimexpr2\hsize+2\tabcolsep\relax}
\begin{document}
\begin{table}[!th]
\setlength\tabcolsep{2pt} % default: 6pt
\caption{Table}
\begin{tabularx}{\textwidth}{@{} l *{6}{R} @{}}
\toprule
& \multicolumn{6}{c@{}}{Title} \\
\cmidrule(l){2-7}
& \multicolumn{2}{>{\hsize=\myhsize\linewidth=\hsize}C}{\texttt{Col\#1 title starts here}}
& \multicolumn{2}{>{\hsize=\myhsize\linewidth=\hsize}C}{\texttt{Col\#2 title starts here}}
& \multicolumn{2}{>{\hsize=\myhsize\linewidth=\hsize}C@{}}{\texttt{Col\#3 title starts here}}\\
\midrule
Title \#1
& \multicolumn{2}{r}{\num{44444}}
& \multicolumn{2}{r}{\num{222222}}
& \multicolumn{2}{r@{}}{\num{1111111}} \\
\midrule
\quad Title\#2 here
& \num{44444} & (99.99\%)
& \num{222222} & (99.99\%)
& \num{1111111} & (99.99\%) \\
\midrule
\qquad Title\#3 here
& \num{44444} & (99.99\%)
& \num{222222} & (99.99\%)
& \num{1111111} & (99.99\%)\\
\qquad\quad Title \#4 here
& \num{33333} & (77.77\%)
& \num{666666} & (22.22\%)
& \num{1111111} & (111\%)\\
\qquad\qquad Title\#5 here
& \num{77} & (2.22\%)
& \num{361} & (0.59\%)
& \num{444444} & (33.33\%)\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}