表格:将条目移至中心并使空白均匀

表格:将条目移至中心并使空白均匀

我有下面这个表格。如何让白色间距均匀,并将 0 放在中间?

\begin{table}\centering
\scriptsize
\begin{tabularx}{\linewidth}{@{}l *{1}{>{\centering\arraybackslash}X} c *{5}{>{\centering\arraybackslash}X} c *{4}{>{\centering\arraybackslash}X} }
\toprule
    & \multicolumn{1}{c}{Train (Complete)} & \multicolumn{5}{c}{Test (Complete)} & & \multicolumn{4}{c}{Test (Truncated)} \\
    \cmidrule(l{2pt}r{2pt}){2-2} \cmidrule(l{2pt}r{2pt}){3-7} \cmidrule(l{2pt}r{2pt}){9-12}
    & 0s & 0s & 1s & 2s & 3s & 4s & & 1s & 2s & 3s & 4s \\
    \midrule
Single Image & 65k,175k & 10k,24k & - & - & - & - & & 1.8k, 23k & - & 46.3 & 46.0 \\
Single Keypoint & 59k,121k & 9k,18k & - & - & - & - & & 1.7k, 18k & - & - & - \\
\midrule
Multiple Image & 60k,150k & 9k,20k & - & - & - & - & & 1.5k, 19k & - & - & - \\
Multiple Keypoints & 54k,98k & 8k,15k & - & - & - & - & & 1.4k, 14k & - & - & - \\
\bottomrule
\end{tabularx}
\caption{}
\label{tab:traintestsplit}
\end{table}

在此处输入图片描述

答案1

您的某些 X 列太窄。我将它们转换为c,然后删除了multicolumn两个不必要的位置。此外,我添加了一个额外的空列作为新的第四列来平衡空白。另一种可能性是删除两个空列并将其替换为固定宽度的空间,方法是使用!{\hspace{<wd>}}

\documentclass{article}
\usepackage{tabularx, booktabs, 
\usepackage[left=3cm, right=3cm]{geometry}

\begin{document}

\begin{table}\centering
\scriptsize
\begin{tabularx}{\linewidth}{@{}l *{3}{c} *{4}{>{\centering\arraybackslash}X} cc *{3}{>{\centering\arraybackslash}X}@{}}

\toprule

& {Train (Complete)} && \multicolumn{5}{@{}c@{}}{Test (Complete)} && \multicolumn{4}{@{}c@{}}{Test (Truncated)} \\

\cmidrule(lr){2-2} \cmidrule(lr){4-8} \cmidrule(l){10-13}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

                   & {0s}      && 0s      & 1s & 2s & 3s & 4s && 1s & 2s & 3s & 4s \\ \midrule

Single Image       &  65k,175k && 10k,24k & - & - & - & - && 1.8k,23k & - & 46.3 & 46.0 \\
Single Keypoint    & 59k,121k  && 9k,18k  & - & - & - & - && 1.7k,18k & - & - & - \\ \midrule
Multiple Image     & 60k,150k  && 9k,20k  & - & - & - & - && 1.5k,19k & - & - & - \\
Multiple Keypoints & 54k,98k   && 8k,15k  & - & - & - & - & & 1.4k,14k & - & - & - \\ \bottomrule
\end{tabularx}
\caption{}
\label{tab:traintestsplit}
\end{table}

在此处输入图片描述

答案2

我会以不同的方式分布列和它们的宽度:

\documentclass{article}
\usepackage[margin=3cm]{geometry}
\usepackage{booktabs,tabularx}

\begin{document}
\begin{table}\centering
\scriptsize
\setlength\cmidrulekern{0.25em}
\begin{tabularx}{\linewidth}{@{}
            l
        >{\raggedleft\hsize=1.2\hsize}X@{,}>{\raggedright\hsize=1.2\hsize}X
            r@{,}l
        *{4}{>{\centering\arraybackslash\hsize=0.9\hsize}X}
            r@{,}l
        *{3}{>{\centering\arraybackslash}X}
                                @{}}
    \toprule
                    & \multicolumn{2}{c}{Train (Complete)}
                                & \multicolumn{6}{c}{Test (Complete)}
                                                      & \multicolumn{5}{c}{Test (Truncated)} \\
    \cmidrule(lr){2-3}
    \cmidrule(lr){4-9}
    \cmidrule(l){10-14}

    & \multicolumn{2}{@{}c}{0s}
                    & \multicolumn{2}{c}{0s}
                                  & 1s & 2s & 3s & 4s & \multicolumn{2}{c}{1s}
                                                                    & 2s & 3s   & 4s  \\ \midrule
Single Image
    & 65k & 175k   & 10k & 24k  & -  & -  & -  & -  & 1.8k & 23k & -  & 46.3 & 46.0\\
Single Keypoint
    & 59k & 121k   & 9k  & 18k  & -  & -  & -  & -  & 1.7k & 18k & -  & -    & -   \\ \midrule
Multiple Image
    & 60k& 150k    & 9k  & 20k  & -  & -  & -  & -  & 1.5k & 19k & -  & -    & -   \\
Multiple Keypoints
    & 54k &98k     & 8k  & 15k  & -  & -  & -  & -  & 1.4k & 14k & -  & -    & -   \\
    \bottomrule
\end{tabularx}
\caption{}
\label{tab:traintestsplit}
\end{table}

\end{document}

在此处输入图片描述

相关内容