多行表

多行表

我有以下 MWE:

\documentclass{standalone}
    
    \usepackage{tabularx}
    \begin{document}
    \begin{tabularx}{\textwidth}{c ccc c cccc}
     & \multicolumn{5}{c}{N} &  \\ 
    W & 7 & 9 & 13 & 17 & 19 & 1 \\ \hline
    0.6078 & 1.0592 (4)& 1.0646 (4) & 1.0647 (6) & 1.0647 (5) & 1.0647 (5) & 1.0647 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    \end{tabularx}
    \end{document}

我想在表格前面添加一列,并为所有包含 S 的 10 行添加标签。

我知道我可以使用 \multirow 来做到这一点,但老实说,我不知道该怎么做。

有什么帮助吗?提前致谢

答案1

  • 对于使用˛tabularx package you should define\textwidth of page layout, for example with optionvarwidth=34em`
  • tabularx表应至少有一个X或从中派生出具有新列的列类型,您的表有 8 列,但您定义了 0 列(没有新列)。
  • 列标题应该如何显示并不完全清楚。因此我\cline在多列单元格下方添加了一个:
\documentclass[margin=3mm, varwidth=34em]{standalone}
\usepackage{multirow, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}
\setlength\tabcolsep{4pt}
    \begin{tabularx}{\linewidth}{@{} c c CCCCC c @{}}
    &        & \multicolumn{5}{c}{N}                                          &         \\
    \cline{3-7}
    & W      & 7          & 9          & 13         & 17         & 19         & 1       \\
    \hline
\multirow{10}{*}{S}
    & 0.6078 & 1.0592 (4) & 1.0646 (4) & 1.0647 (6) & 1.0647 (5) & 1.0647 (5) & 1.0647  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
\end{tabularx}
\end{document}

在此处输入图片描述

附录:
使用包tblrtabularray您可以编写一个更加花哨(易于阅读)的表格,其中包含c列(类似于@Pieter van Oostrum 答案中使用的列)并按行进行分组:

\documentclass[margin=3mm]{standalone}
\usepackage{tabularray}

\begin{document}
    \begin{tblr}{colsep=4pt,
                 colspec={@{} *{8}{c} @{}},
                 rowsep=1pt,
                 row{even[3]} = {belowsep=1ex}
                 }
    &        & \SetCell[c=5]{c} N                                             
                          &            &            &            &            &         \\
    \cline{3-7}
tip & W      & 7          & 9          & 13         & 17         & 19         & 1       \\
    \hline
\SetCell[r=10]{c}   S
    & 0.6078 & 1.0592 (4) & 1.0646 (4) & 1.0647 (6) & 1.0647 (5) & 1.0647 (5) & 1.0647  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
\end{tblr}
\end{document}

在此处输入图片描述

答案2

c像这样吗?注意:我调整了列规范中的 s数量,因为它是错误的,并将其\multicolumn改为 7。

\documentclass{standalone}
    
    \usepackage{multirow}
    \begin{document}
    \begin{tabular}{ ccc c cccc}
     & \multicolumn{7}{c}{N} \\ 
    & W & 7 & 9 & 13 & 17 & 19 & 1 \\ \hline
    \multirow{10}{*}{S} & 0.6078 & 1.0592 (4)& 1.0646 (4) & 1.0647 (6) & 1.0647 (5) & 1.0647 (5) & 1.0647 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    \end{tabular}
    \end{document}

在此处输入图片描述

相关内容