表格标题未左对齐

表格标题未左对齐

我正在写一篇文章,并使用 Elsevier 的 LATEX 双列模式。有一个宽表必须放入两列中。我使用了 table*,但表的标题没有左对齐。我该如何解决这个问题?

\begin{table*}[]
\centering
\caption{}
\label{tab:my-table}
\resizebox{\textwidth}{!}{%
\begin{tabular}{lccccccccc}
\hline
& \multicolumn{1}{l}{} & \multicolumn{2}{c}{Title} & \multicolumn{1}{l} 
{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} 
& \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\ \cline{3-4}
Title 1 & Title 1 & Title 1 & Title 1 & Title 1 & Title 1 & Title 1 & 
Title 1 & Title 1 & Title 1 \\ \hline
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
\multicolumn{1}{c}{\textbf{xxxxxxx}} & xxxxxxx & xxxxxxx & xxxxxxx & 
xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx \\ \hline
\end{tabular}%
}
\end{table*}

提前致谢。

桌子

答案1

回答得晚了,但希望它能对别人有所帮助:-)

不幸的是,答案提供了 OP,但没有提供他测试过的信息。因此,他的说法无法得到证实,更糟糕的是,使用article文档类在标准文档示例中进行测试表明,这是错误的:

  • 代码片段中的第一行代码\begin{table*}[width=\textwidth]有误。\begin{table}例如,只能遵循放置选项[htbp]。但是, \begin{table*}始终位于插入表格的下一页的顶部,因此不会考虑任何放置选项。
  • 如果使用caption或类似的包,则标题位置会受到影响。使用caption,将标题推到表格左侧的选项示例如下:
\usepackage[skip=1ex, % vertical space between caption and table
            singlelinecheck=false]{caption}
  • \resizebox{...}应尽可能避免使用(因为它会使表格中的字体大小与表格外的字体不一致)。最好规定表格宽度。

解决 OP 问题的可能 MWE 可以是:

\documentclass[twocolumn]{article}
\usepackage[skip=1ex,
            singlelinecheck=false]{caption}

%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document

\begin{document}
\begin{table*}
    \centering
    \setlength\tabcolsep{0pt}
\caption{Caption text}
\label{tab:my-table}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} lccccccccc}
    \hline
    &   & \multicolumn{2}{c}{Title} 
                &   &   &   &   &       \\
    \cline{3-4}
Title 1 & Title 2 & Title 3 & Title 4 & Title 5 
        & Title 6 & Title 7 & Title 8 & Title 9 
        & Title 10          \\ 
    \hline
Researcher 1 
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
        & xxxxxxx \\
Researcher 2
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 3
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 4
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 5
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 6
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
\multicolumn{1}{c}{\textbf{xxxxxxx}} 
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
    \hline
\end{tabular*}
\end{table*}
\end{document}

其中列之间的距离留给 LaTeX(宏@{\extracolsep{\fill}})。编译结果是

-

(红线表示文本边框)。

另一种可能的解决方案是使用tabularray包(带有库booktabs,加载同名包)并手动设置列之间的距离:

\documentclass[twocolumn]{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
  \ExplSyntaxOn
\NewChildSelector{eachthree}
  {
    \int_step_inline:nnnn {6}{3}{\l_tblr_childs_total_tl}
      { \clist_put_right:Nn \l_tblr_childs_clist {##1} }
  }
\ExplSyntaxOff

\usepackage[skip=1ex,
            singlelinecheck=false]{caption}

%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document


\begin{document}
\begin{table*}
\caption{Caption text}
\small  % <---
\label{tab:my-table}
\begin{tblr}{width=\textwidth,
             colsep = 3pt,   % <---
             colspec = {@{} l *{9}{X[c]}@{}},
             row{3-Z}={rowsep=0pt},
             row{eachthree} = {abovesep=1ex},
             }
    \toprule
    &   & \SetCell[c=2]{c}  Title 
            &   &   &   &   &   &       \\
    \cmidrule{3-4}
Title 1 & Title 2 & Title 3 & Title 4 & Title 5
        & Title 6 & Title 7 & Title 8 & Title 9
        & Title 10          \\
    \midrule
Researcher 1
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 2
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 3
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 4
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 5
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
Researcher 6
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
\SetCell{c,font=\bfseries} xxxxxxx 
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx
        & xxxxxxx \\
    \hline
\end{tblr}%
    \end{table*}
\end{document}

在此处输入图片描述

答案2

我补充道“[宽度=\文本宽度]“并且表格标题左对齐。

\begin{table*}[width=\textwidth]
\centering
\caption{}
\label{tab:my-table}
\resizebox{\textwidth}{!}{%
\begin{tabular}{lccccccccc}
\hline
& \multicolumn{1}{l}{} & \multicolumn{2}{c}{Title} & \multicolumn{1}{l} 
{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} 
& \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\ \cline{3-4}
Title 1 & Title 1 & Title 1 & Title 1 & Title 1 & Title 1 & Title 1 & 
Title 1 & Title 1 & Title 1 \\ \hline
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
Researcher1 & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx 
& xxxxxxx & xxxxxxx & xxxxxxx \\
\multicolumn{1}{c}{\textbf{xxxxxxx}} & xxxxxxx & xxxxxxx & xxxxxxx & 
xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx & xxxxxxx \\ \hline
\end{tabular}%
}
\end{table*}

相关内容