表格第一列有不需要的空白,前两行空白

表格第一列有不需要的空白,前两行空白

谁能帮我去掉第一列的多余宽度,目标是像第二幅图像(取自word)那样 - 代码如下,生成下面的图像 1。

\begin{table}[]
\centering
\def\arraystretch{1.5}%
\resizebox{\textwidth}{!}{%
\begin{tabular}{ccccccccc}
\hline
& \multicolumn{4}{c}{Experiment 2} & \multicolumn{4}{c}{Experiment 4} \\ \cline{2-9} 
& 3.5°   & 7°     & 10.5°  & 14°   & 0.875°  & 1.75°  & 3.5°  & 10.5° \\ \hline
Size              & 4.00   & 5.77   & 7.54   & 9.32  & 1.34    & 1.56   & 2.00  & 3.77  \\
Scale Factor      & 1.00   & 1.44   & 1.89   & 2.33  & 0.33    & 0.39   & 0.50  & 0.94  \\ \hline
SpatialFrequency & 1.00   & 0.69   & 0.53   & 0.43  & 1.50    & 1.28   & 1.00  & 0.53  \\
Scale Factor      & 1.00   & 0.69   & 0.53   & 0.43  & 1.50    & 1.28   & 1.00  & 0.53  \\ \hline
\stoptable{\textit{Note: Scale factors are relative to the size and spatial frequency of the 3.5° condition in Experiment 2.}}
\end{tabular}%
}
\caption{Sizes, spatial frequencies, and their associated scale factors for the four eccentricity conditions in Experiments 2 and 4.}
\label{tab2_9}
\end{table}

带有空格的表格

没有空白的图像

答案1

与。{NiceTabular}nicematrix

\documentclass{article}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage{caption}

\begin{document}

\begin{table}
\centering
\begin{NiceTabular}{@{}l*{8}{X[c]}@{}}%
[tabularnote =  \itshape Scale factors are relative to the size and 
     spatial frequency of the 3.5° condition in Experiment 2. ]
    \toprule
    \RowStyle[bold]{}
    & \Block{1-4}{Experiment 2} & & & & \Block{1-4}{Experiment 4} \\
    \cmidrule(r){2-5} 
    \cmidrule(l){6-9}
        & 3.5°     & 7°       & 10.5°    & 14°
        & 0.875°   & 1.75°    & 3.5°     & 10.5° \\
    \midrule
    Size    & 4.00  & 5.77  & 7.54  & 9.32  & 1.34  & 1.56  & 2.00  & 3.77  \\
    Scale Factor      
            & 1.00  & 1.44  & 1.89  & 2.33  & 0.33  & 0.39  & 0.50  & 0.94  \\  \midrule
    Spatial Frequency 
            & 1.00  & 0.69  & 0.53  & 0.43  & 1.50  & 1.28  & 1.00  & 0.53  \\
    Scale Factor      
        & 1.00  & 0.69  & 0.53  & 0.43  & 1.50  & 1.28  & 1.00  & 0.53  \\ 
    \bottomrule
\end{NiceTabular} 

\caption{Sizes, spatial frequencies, and their associated scale factors for the four eccentricity conditions in Experiments 2 and 4.}
\label{tab2_9}
\end{table}

\end{document}

您需要多次编译(因为nicematrix在后台使用 PGF/Tikz 节点)。

上述代码的输出

答案2

另一种方法是使用tabularray包。其talltblr环境提供了remark下表中注释的功能:

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

\begin{document}
    \begin{table}
    \centering
\DefTblrTemplate{firsthead}{default}{} % <---
\SetTblrStyle{remark}{\small\itshape}
\begin{talltblr}[
remark{Note} = {Scale factors are relative to the size and spatial frequency of the \ang{3.5} condition in Experiment 2.}
                ]{colsep=2pt,
                  colspec = {@{} l*{8}{X[c, si={table-format=1.2{*}}]}
                            @{}   },
                row{1} = {font=\bfseries}                  
                }
    \toprule
    &\SetCell[c=4]{c}   {{{Experiment 2}}}
        &       &       &       &\SetCell[c=4]{c}   {{{Experiment 4}}}       
                                        &       &       &       \\
    \cmidrule[r]{2-5} 
    \cmidrule[l]{6-9}
        & \ang{3.5}     & \ang{7}       & \ang{10.5}    & \ang{14}   
        & \ang{0.875}   & \ang{1.75}    & \ang{3.5}     & \ang{10.5} \\
    \midrule
Size    & 4.00  & 5.77  & 7.54  & 9.32  & 1.34  & 1.56  & 2.00  & 3.77  \\
Scale Factor      
        & 1.00  & 1.44  & 1.89  & 2.33  & 0.33  & 0.39  & 0.50  & 0.94  \\  \midrule[dashed]
Spatial Frequency 
        & 1.00  & 0.69  & 0.53  & 0.43  & 1.50  & 1.28  & 1.00  & 0.53  \\
Scale Factor      
        & 1.00  & 0.69  & 0.53  & 0.43  & 1.50  & 1.28  & 1.00  & 0.53  \\ 
    \bottomrule
\end{talltblr} 

\caption{Sizes, spatial frequencies, and their associated scale factors for the four eccentricity conditions in Experiments 2 and 4.}
\label{tab2_9}
    \end{table}
\end{document}

在此处输入图片描述

答案3

\stoptable指令——您是否可能从基于 ConTeXt 的示例中复制了它?——似乎没有定义。因此,LaTeX 只是将指令的参数转储到恰好是第一列的位置。正如其他人已经指出的那样,只需将图例以下主要表格材料。

我还强烈建议您不要\resizebox对表格施加大锤,而是使用tabularx环境并将X列类型应用于第一列。用包的宏替换\hline和也是一个不错的选择。\clinebooktabs

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx,booktabs}
\begin{document}

\begin{table}[htbp]

\begin{tabularx}{\textwidth}{@{} X *{8}{c} @{}}
\toprule
& \multicolumn{4}{c}{Experiment 2} 
& \multicolumn{4}{c@{}}{Experiment 4} \\ 
\cmidrule(lr){2-5} \cmidrule(l){6-9}
                  & 3.5°  & 7°   & 10.5° & 14°  & 0.875°& 1.75°& 3.5° & 10.5° \\ 
\midrule
Size              & 4.00  & 5.77 & 7.54  & 9.32 & 1.34  & 1.56 & 2.00 & 3.77  \\
Scale Factor      & 1.00  & 1.44 & 1.89  & 2.33 & 0.33  & 0.39 & 0.50 & 0.94  \\ 
\addlinespace
Spatial Frequency & 1.00  & 0.69 & 0.53  & 0.43 & 1.50  & 1.28 & 1.00 & 0.53  \\
Scale Factor      & 1.00  & 0.69 & 0.53  & 0.43 & 1.50  & 1.28 & 1.00 & 0.53  \\ 
\bottomrule
\addlinespace
\multicolumn{9}{@{}p{\textwidth}@{}}{\small\textit{Note}:
    Scale factors are relative to the size and spatial frequency 
    of the 3.5° condition in Experiment 2.}
\end{tabularx}

\caption{Sizes, spatial frequencies, and associated scale factors for the four eccentricity conditions in Experiments 2 and 4.}
\label{tab2_9}
\end{table}

\end{document}

相关内容