这是制作表格的正确方法吗?

这是制作表格的正确方法吗?

在阅读了教程、文档和帖子后,我尝试自己设计一个表格。最终结果看起来完全符合预期 :-)

但是,我不确定我是否做对了。在我看来,代码看起来相当混乱。

所以我的问题是,有没有更好/更优雅的方法来设计这个表格?

\documentclass[acmsmall]{acmart}
\usepackage{float}
\usepackage{multirow} 
\usepackage{rotating} 
\usepackage{verbatim} 
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}

\begin{table}
  \caption{Table}

  \begin{tabularx}{\textwidth}{llXcccccc}
  \toprule
   {} & {} & {} & \multicolumn{5}{c}{Implic. QA} & {\multirow{2}{*}{\rotatebox[origin=r, y=5pt]{90}{Dtaa Lnq.}}}  \\
    \cmidrule(lllll){4-8}
     Source & NBame & Description & \rotatebox{90}{Accin.} & \rotatebox{90}{Lomp.} & \rotatebox{90}{Ronsi.} & \rotatebox{90}{Volti.} & \rotatebox{90}{Curre.} &  \\ \addlinespace
   
    \midrule
    
     \multirow{4}{*}{\shortstack[l]{Hugo \\ et al.}} & \multirow{4}{*}{Brasilia} & The organization, The organization The organization, The organization, The organization, The organization, The organization, The organization. & \multirow{4}{*}{-}  & \multirow{4}{*}{-} & \multirow{4}{*}{x} & \multirow{4}{*}{-} & \multirow{4}{*}{-} & \multirow{4}{*}{-} \\ \addlinespace
     
     \multirow{3}{*}{\shortstack[l]{Manuel \\et al.}} & \multirow{3}{*}{Nort Carolina} & Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image & \multirow{3}{*}{-}  & \multirow{3}{*}{x} & \multirow{3}{*}{x} & \multirow{3}{*}{-} & \multirow{3}{*}{-} & \multirow{3}{*}{-} \\ \addlinespace
    
     \multirow{2}{*}{\shortstack[l]{Otto \\ et al.}} & \multirow{2}{*}{Manchester} & Image Image Image Image Image Image Image Image & \multirow{2}{*}{-}  & \multirow{2}{*}{-} & \multirow{2}{*}{-} & \multirow{2}{*}{-} & \multirow{2}{*}{-} & \multirow{2}{*}{-} \\ \addlinespace%[20pt]
     
     \multirow{2}{*}{\shortstack[l]{Marx \\\& Weak}} & \multirow{2}{*}{France} & Image Image Image Image Image Image Image Image & \multirow{2}{*}{x}  & \multirow{2}{*}{x} & \multirow{2}{*}{-} & \multirow{2}{*}{-} & \multirow{2}{*}{x} & \multirow{2}{*}{x} \\ \addlinespace
     
     \multirow{2}{*}{\shortstack[l]{Oliver \\\& Wolfor}} & \multirow{2}{*}{Germany} & Image Image Image Image Image Image Image Image & \multirow{2}{*}{-}  & \multirow{2}{*}{-} & \multirow{2}{*}{-} & \multirow{2}{*}{x} & \multirow{2}{*}{-} & \multirow{2}{*}{x} \\ \addlinespace
    
     \multirow{3}{*}{\shortstack[l]{Humbold \\et al.}} & \multirow{3}{*}{Hunbary} & Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image & \multirow{3}{*}{-}  & \multirow{3}{*}{-} & \multirow{3}{*}{-} & \multirow{3}{*}{x} & \multirow{3}{*}{-} & \multirow{3}{*}{-} \\ 
    
  \bottomrule
  \end{tabularx}
\end{table}

\end{document}

在此处输入图片描述

请忽略表格的内容。

非常感谢,并致以最诚挚的问候,Harald

答案1

一切都很好,但是有太多不必要的\multirows。实际上,您不需要在表格主体中添加任何 s。问题可能是列X默认垂直对齐到顶部而不是中间。文档tabularx提供了有关如何更改此设置的想法。

我对如何改进代码的建议是:

\documentclass[acmsmall]{acmart}
\usepackage{float}
\usepackage{multirow} 
\usepackage{rotating} 
\usepackage{verbatim} 
\usepackage{tabularx}
\usepackage{booktabs}

\renewcommand{\tabularxcolumn}[1]{m{#1}}

\begin{document}

\begin{table}
 \caption{Table}

 \begin{tabularx}{\textwidth}{m{1.3cm}lXcccccc}
  \toprule
   {} & {} & {} & \multicolumn{5}{c}{Implic. QA} & {\multirow{2}{*}{\rotatebox[origin=r, y=5pt]{90}{Dtaa Lnq.}}}  \\
    \cmidrule(lllll){4-8}
     Source & NBame & Description & \rotatebox{90}{Accin.} & \rotatebox{90}{Lomp.} & \rotatebox{90}{Ronsi.} & \rotatebox{90}{Volti.} & \rotatebox{90}{Curre.} &  \\ \addlinespace
    \midrule
    Hugo et al. & Brasilia & The organization, The organization The organization, The organization, The organization, The organization, The organization, The organization. & -  & - & x & - & - & - \\ \addlinespace
    Manuel et al. & Nort Carolina & Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image & -  & x & x & - & - & - \\ \addlinespace
    Otto\break et al. & Manchester & Image Image Image Image Image Image Image Image & - & - & - & - & - & - \\ \addlinespace%[20pt]
    Marx\break \& Weak & France & Image Image Image Image Image Image Image Image & x  & x & - & - & x & x \\ \addlinespace
    Oliver\break \& Wolfor & Germany & Image Image Image Image Image Image Image Image & -  & - & - & x & - & x \\ \addlinespace
    Humbold et al. & Hunbary & Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image & - & - & - & x & - & - \\ 
  \bottomrule
  \end{tabularx}
\end{table}

\end{document}

在此处输入图片描述

答案2

下列表格代码的简化版本应该会产生类似的输出。

在此处输入图片描述

\documentclass[acmsmall]{acmart}
\usepackage{float}
\usepackage{multirow} 
\usepackage{rotating} 
\usepackage{verbatim} 
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}

\begin{table}
  \caption{Table}
  \renewcommand{\tabularxcolumn}[1]{m{#1}}
  \begin{tabularx}{\textwidth}{>{\raggedright\arraybackslash}m{1.25cm}lXcccccc}
  \toprule
   {} & {} & {} & \multicolumn{5}{c}{Implic. QA} & {\multirow{2}{*}{\rotatebox[origin=r, y=5pt]{90}{Dtaa Lnq.}}}  \\
    \cmidrule(lr){4-8}
     Source & NBame & Description & \rotatebox{90}{Accin.} & \rotatebox{90}{Lomp.} & \rotatebox{90}{Ronsi.} & \rotatebox{90}{Volti.} & \rotatebox{90}{Curre.} &  \\ \addlinespace
   
    \midrule
    
     Hugo et al. 
       & Brasilia 
         & The organization, The organization The organization, The organization, The organization, The organization, The organization, The organization. 
           & -  & - & x & - & - & - \\ \addlinespace
     
     Manuel et al. 
       & Nort Carolina 
         & Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image 
           & - & x & x & - & - & - \\ \addlinespace
    
     Otto et al. 
       & Manchester 
         & Image Image Image Image Image Image Image Image 
           & - & - & - & - & - & - \\ \addlinespace%[20pt]
     
     Marx \& Weak 
       & France 
         & Image Image Image Image Image Image Image Image 
           & x  & x & - & - & x & x \\ \addlinespace
     
     Oliver \& Wolfor 
       & Germany 
         & Image Image Image Image Image Image Image Image 
           & - & - & - & x & - & x \\ \addlinespace
    
     Humbold et al. 
       & Hunbary 
         & Image Image Image Image Image Image Image Image Image Image Image Image Image Image Image 
           & - & - & - & x & - & - \\ 
    
  \bottomrule
  \end{tabularx}
\end{table}

\end{document}

相关内容