tabularx 中的多行

tabularx 中的多行

我想用 multirow() 替换缓冲区列,这样缓冲区的值就正好在中间。我该怎么做?

\begin{table*}[!t]
\centering
\scriptsize
\begin{tabularx}{0.9\linewidth}{@{}llcccccccc@{}}
\toprule
 &   &\multicolumn{4}{c}{\textit{Disjoint}} & \multicolumn{4}{c}{\textit{Blurry10}}\\
\cmidrule(l{0.5em}r{0.5em}){3-6} \cmidrule(l{0.5em}r{0.5em}){7-10}

 &  & \multicolumn{2}{c}{\textit{CIFAR-100}} & \multicolumn{2}{c}{\textit{TinyImageNet}} & \multicolumn{2}{c}{\textit{CIFAR-100}} & \multicolumn{2}{c}{\textit{TinyImageNet}} \\
\cmidrule(l{0.5em}r{0.5em}){3-4} \cmidrule(l{0.5em}r{0.5em}){5-6} \cmidrule(l{0.5em}r{0.5em}){7-8} \cmidrule(l{0.5em}r{0.5em}){9-10}

\textbf{Buffer} & \textbf{Method} & \textbf{Acc} & \textbf{F} & \textbf{Acc} & \textbf{F}  & \textbf{Acc} & \textbf{F} & \textbf{Acc} & \textbf{F}  \\
\midrule
       &   EWC    &      &      &      &      &      &      & 95.2 & 90.9 \\
       &   RWalk  & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
500    &    EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
       &   RWalk  & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
       &    EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
       &   RWalk  & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\midrule
   &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
  &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
    &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
1000   &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
  &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
 &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
 \midrule
  &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
   &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
   &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
2000  &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
  &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
   &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\bottomrule
\end{tabularx}
\caption{Accuracy and forgetting of all the experiments over 3 seeds.}
\label{tab:tabular_data}
\end{table*}

答案1

我看不出tabularx对手头的材料使用环境的理由,因为(a)单元格内的自动换行既没有必要也不需要,并且(b)没有必要强制某些列(比如,8 个数据列)具有相同的宽度。

我建议你使用一个普通的tabular环境,放弃这个\scriptsize指令,摆脱斜体大胆的在标题单元格中,并用 替换内部\midrule指令\addlinespace

也就是说,如果您可以让“TinyImageNet”标题稍微短一些,表格的整体外观就会明显改善。

在此处输入图片描述

\documentclass[twocolumn]{article}
\usepackage{tabularx,booktabs}
\begin{document}

\begin{table*} % will be placed at top of page b/c 'twocolumn' is in effect
\centering

\begin{tabular}{@{} ll *{8}{c} @{}}
\toprule
Buffer & Method & \multicolumn{4}{c}{Disjoint} 
                & \multicolumn{4}{c@{}}{Blurry10} \\
\cmidrule(lr){3-6} \cmidrule(l){7-10}
 & & \multicolumn{2}{c}{CIFAR-100} 
   & \multicolumn{2}{c}{TinyImageNet} 
   & \multicolumn{2}{c}{CIFAR-100} 
   & \multicolumn{2}{c@{}}{TinyImageNet} \\
\cmidrule(lr){3-4} \cmidrule(lr){5-6} 
\cmidrule(lr){7-8} \cmidrule(l){9-10}

 & & Acc & F & Acc & F & Acc & F & Acc & F  \\
\midrule
500   &   EWC        &      &      &      &      &      &      & 95.2 & 90.9 \\
      &   RWalk      & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
      &    EWC       & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
      &   RWalk      & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
      &    EWC       & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
      &   RWalk      & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\addlinespace
1000 &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\addlinespace
2000 &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     &    EWC        & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     &   RWalk       & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\bottomrule
\end{tabular}

\caption{Accuracy and forgetting of all experiments over three seeds.}
\label{tab:tabular_data}
\end{table*}

\end{document}

答案2

你的表格主体应该是这样的:

    \begin{table*}[!ht]
\centering
%\scriptsize
\begin{tabularx}{0.9\linewidth}{@{}XXcccccccc@{}}
\toprule
    &   &\multicolumn{4}{c}{\textit{Disjoint}} & \multicolumn{4}{c}{\textit{Blurry10}}\\
    \cmidrule(l{0.5em}r{0.5em}){3-6} 
    \cmidrule(l{0.5em}r{0.5em}){7-10}

    &   & \multicolumn{2}{c}{\textit{CIFAR-100}} & \multicolumn{2}{c}{\textit{TinyImageNet}} & \multicolumn{2}{c}{\textit{CIFAR-100}} & \multicolumn{2}{c}{\textit{TinyImageNet}} \\
    \cmidrule(l{0.5em}r{0.5em}){3-4} \cmidrule(l{0.5em}r{0.5em}){5-6} \cmidrule(l{0.5em}r{0.5em}){7-8} \cmidrule(l{0.5em}r{0.5em}){9-10}

\textbf{Buffer} & \textbf{Method} & \textbf{Acc} & \textbf{F} & \textbf{Acc} & \textbf{F}  & \textbf{Acc} & \textbf{F} & \textbf{Acc} & \textbf{F}  \\
    \midrule
\multirow{6}{=}{500}
    &   EWC      &      &      &      &      &      &      & 95.2 & 90.9 \\
    &   RWalk    & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
    &    EWC     & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
    &   RWalk    & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
    &    EWC     & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
    &   RWalk    & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\midrule
\multirow{6}{=}{1000}
    &    EWC    & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
    &   RWalk   & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
    &    EWC    & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
    &   RWalk   & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
    &    EWC    & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
    &   RWalk   & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
 \midrule
\multirow{6}{=}{2000}
    &    EWC    & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
    &   RWalk   & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
    &    EWC    & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
    &   RWalk   & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
    &    EWC    & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
    &   RWalk   & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\bottomrule
\end{tabularx}
\caption{Accuracy and forgetting of all the experiments over 3 seeds.}
\label{tab:tabular_data}
    \end{table*}

对于完整文档 (MWE),您需要先在问题中提供它。我们没有关于您的文档的任何信息(请参阅@Mico 评论)。

答案3

我会把这些话放在顶部行:这是标题,不是吗?

另外,请考虑一下,tabularx没有X列是行不通的。您需要改为这样做tabular*。我还建议siunitx使用一个小技巧,使子标题的宽度相同。

无需使用粗体。

\documentclass{article}
\usepackage{tabularx,booktabs,siunitx}

\newlength{\baksterlen}

\begin{document}

\begin{table*}[!t]
\centering
\small
\setlength{\tabcolsep}{0pt}
\settowidth{\baksterlen}{\textit{TinyImageNet}}


\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  S[table-format=4.0]
  l
  *{8}{S[table-format=2.1]}
}
\toprule
{Buffer} &
Method &
\multicolumn{4}{c}{\textit{Disjoint}} &
\multicolumn{4}{c}{\textit{Blurry10}}\\
\cmidrule{3-6} \cmidrule{7-10}

& &
\multicolumn{2}{c}{\makebox[\baksterlen]{\textit{CIFAR-100}}} &
\multicolumn{2}{c}{\textit{TinyImageNet}} &
\multicolumn{2}{c}{\makebox[\baksterlen]{\textit{CIFAR-100}}} &
\multicolumn{2}{c}{\textit{TinyImageNet}} \\
\cmidrule{3-4} \cmidrule{5-6} \cmidrule{7-8} \cmidrule{9-10}

& & {Acc} & {F} & {Acc} & {F}  & {Acc} & {F} & {Acc} & {F} \\
\midrule
 500 & EWC   &      &      &      &      &      &      & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     & EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     & EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\midrule
1000 & EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     & EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     & EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\midrule
2000 & EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     & EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
     & EWC   & 92.4 & 54.0 & 93.4 & 82.4 & 95.2 & 90.9 & 95.2 & 90.9 \\
     & RWalk & 73.2 & 32.4 & 74.1 & 55.9 & 67.4 & 48.9 & 67.4 & 48.9 \\
\bottomrule
\end{tabular*}

\caption{Accuracy and forgetting of all the experiments over 3 seeds.}
\label{tab:tabular_data}

\end{table*}

\end{document}

在此处输入图片描述

相关内容