一个表中的多个表:合并行

一个表中的多个表:合并行

要创建的表

\documentclass{article}
\usepackage{caption}

\begin{document}
    \begin{minipage}[c]{0.5\textwidth}
        \centering
            \captionof{table}{abc}
        \begin{tabular}{|c|c|c|c|c|c|}
            \hline
        \multicolumn{6}{|c|}{{$a = 1$, $b = 1$}} \\
        \hline          
            Cl1 & Cl2 & \multicolumn{2}{|c|}{{Cl3, Cl4}} & \multicolumn{2}{|c|}{{Cl5, Cl6}} \\
             & aa & bb & cc & dd & ee \\            
            \hline
            1 & 4 & 5 & 8 & 11 & 14  \\
            \hline 
            2 &  & 6 & 9 & 12 & 15 \\
            \hline
            3 &  & 7 & 10 & 13 & 16 \\
            \hline          
        \end{tabular}
\bigskip
            \captionof{table}{def}
        \begin{tabular}{|c|c|c|c|c|c|}
    \hline
    \multicolumn{6}{|c|}{{$a = 2$, $b = 2$}} \\
    \hline          
    Cl1 & Cl2 & \multicolumn{2}{|c|}{{Cl3, Cl4}} & \multicolumn{2}{|c|}{{Cl5, Cl6}} \\
    & aa & bb & cc & dd & ee \\         
    \hline
    1 & 6 & 7 & 12 & 17 & 22  \\
    \hline 
    2 &  & 8 & 13 & 18 & 23 \\
    \hline
    3 &  & 9 & 14 & 19 & 24 \\
    \hline          
    4 &  & 10 & 15 & 20 & 25 \\
    \hline
    5 &  & 11 & 16 & 21 & 26 \\
    \hline  
\end{tabular}
    \end{minipage}
    \begin{minipage}[c]{0.5\textwidth}
        \centering
            \captionof{table}{ghi}
\begin{tabular}{|c|c|c|c|c|c|}
    \hline
    \multicolumn{6}{|c|}{{$a = 3$, $b = 3$}} \\
    \hline          
    Cl1 & Cl2 & \multicolumn{2}{|c|}{{Cl3, Cl4}} & \multicolumn{2}{|c|}{{Cl5, Cl6}} \\
    & aa & bb & cc & dd & ee \\         
    \hline
    1 & 10 & 11 & 20 & 29 & 38  \\
    \hline 
    2 &  & 12 & 21 & 30 & 39 \\
    \hline
    3 &  & 13 & 22 & 31 & 40 \\
    \hline          
    4 &  & 14 & 23 & 32 & 41 \\
    \hline
    5 &  & 15 & 24 & 33 & 42 \\
    \hline  
    6 &  & 16 & 25 & 34 & 43 \\
    \hline
    7 &  & 17 & 26 & 35 & 44 \\
    \hline          
    8 &  & 18 & 27 & 36 & 45 \\
    \hline
    9 &  & 19 & 28 & 37 & 46 \\
    \hline      
    \end{tabular}

    \end{minipage}
\end{document}

我可以得到这个

感谢您帮助微调剩余部分!谢谢。

答案1

像这样?

在此处输入图片描述

使用multirow包和\cline{...}

\documentclass{article}
\usepackage{caption}
\usepackage{multirow}

\begin{document}
    \begin{minipage}[t]{0.5\textwidth}
        \centering
            \captionof{table}{abc}
        \begin{tabular}{|c|c|c|c|c|c|}
            \hline
        \multicolumn{6}{|c|}{{$a = 1$, $b = 1$}} \\
        \hline
            Cl1 & Cl2 & \multicolumn{2}{|c|}{{Cl3, Cl4}} & \multicolumn{2}{|c|}{{Cl5, Cl6}} \\
             & aa & bb & cc & dd & ee \\
        \hline
            1 & \multirow{3}{*}{4}
                 & 5 & 8 & 11 & 14  \\
        \cline{1-1}\cline{3-6}
            2 &  & 6 & 9 & 12 & 15 \\
        \cline{1-1}\cline{3-6}
            3 &  & 7 & 10 & 13 & 16 \\
            \hline
        \end{tabular}
\bigskip
            \captionof{table}{def}
        \begin{tabular}{|c|c|c|c|c|c|}
    \hline
    \multicolumn{6}{|c|}{{$a = 2$, $b = 2$}} \\
    \hline
    Cl1 & Cl2 & \multicolumn{2}{|c|}{{Cl3, Cl4}} & \multicolumn{2}{|c|}{{Cl5, Cl6}} \\
    & aa & bb & cc & dd & ee \\
    \hline
    1 & \multirow{5}{*}{6}
         & 7 & 12 & 17 & 22  \\
        \cline{1-1}\cline{3-6}
    2 &  & 8 & 13 & 18 & 23 \\
        \cline{1-1}\cline{3-6}
    3 &  & 9 & 14 & 19 & 24 \\
        \cline{1-1}\cline{3-6}
    4 &  & 10 & 15 & 20 & 25 \\
        \cline{1-1}\cline{3-6}
    5 &  & 11 & 16 & 21 & 26 \\
    \hline
\end{tabular}
    \end{minipage}
%
    \begin{minipage}[t]{0.5\textwidth}
        \centering
            \captionof{table}{ghi}
\begin{tabular}{|c|c|c|c|c|c|}
    \hline
    \multicolumn{6}{|c|}{{$a = 3$, $b = 3$}} \\
    \hline
    Cl1 & Cl2 & \multicolumn{2}{|c|}{{Cl3, Cl4}} & \multicolumn{2}{|c|}{{Cl5, Cl6}} \\
    & aa & bb & cc & dd & ee \\
    \hline
    1 & \multirow{9}{*}{10}
         & 11 & 20 & 29 & 38  \\
        \cline{1-1}\cline{3-6}
    2 &  & 12 & 21 & 30 & 39 \\
        \cline{1-1}\cline{3-6}
    3 &  & 13 & 22 & 31 & 40 \\
        \cline{1-1}\cline{3-6}
    4 &  & 14 & 23 & 32 & 41 \\
        \cline{1-1}\cline{3-6}
    5 &  & 15 & 24 & 33 & 42 \\
        \cline{1-1}\cline{3-6}
    6 &  & 16 & 25 & 34 & 43 \\
        \cline{1-1}\cline{3-6}
    7 &  & 17 & 26 & 35 & 44 \\
        \cline{1-1}\cline{3-6}
    8 &  & 18 & 27 & 36 & 45 \\
        \cline{1-1}\cline{3-6}
    9 &  & 19 & 28 & 37 & 46 \\
    \hline
    \end{tabular}
    \end{minipage}
\end{document}

随着包的使用,tanularray表代码变得更短......

\documentclass{article}
\usepackage{caption}
\usepackage{tabularray}

\begin{document}
    \begin{minipage}[t]{0.5\textwidth}
        \centering
            \captionof{table}{abc}
        \begin{tblr}{hline{1,2,4-Z}=solid, vlines,
                     colspec={*{6}{c}},
                     }
    \SetCell[c=6]{c}    $a = 1$, $b = 1$        \\
    Cl1 & Cl2   & \SetCell[c=2]{c}    Cl3, Cl4
                        &       & \SetCell[c=2]{c}    Cl5, Cl6
                                        &       \\
        & aa    &   bb  &   cc  &   dd  &   ee  \\
    1   & \SetCell[r=3]{c}    4
                &       &       &       \\
    2   &       &   5   &   8   &   11  &  14   \\
    3   &       &   7   &   10  &  13   &   16  \\
    \end{tblr}
\bigskip
            \captionof{table}{def}
        \begin{tblr}{hline{1,2,4-Z}=solid, vlines,
                     colspec={*{6}{c}},
                     }
    \SetCell[c=6]{c}    $a = 2$, $b = 2$        \\
    Cl1 & Cl2   & \SetCell[c=2]{c}    Cl3, Cl4
                        &       & \SetCell[c=2]{c}    Cl5, Cl6
                                        &       \\
        & aa    &   bb  &   cc  &   dd  &   ee  \\
    1   & \SetCell[r=5]{c} 6
                &   7   &   12  &   17  &   22  \\
    2   &       &   8   &   13  &   18  &   23  \\
    3   &       &   9   &   14  &   19  &   24  \\
    4   &       &   10  &   15  &   20  &   25  \\
    5   &       &   11  &   16  &   21  &   26  \\
\end{tblr}
    \end{minipage}
%
    \begin{minipage}[t]{0.5\textwidth}
        \centering
            \captionof{table}{ghi}
        \begin{tblr}{hline{1,2,4-Z}=solid, vlines,
                     colspec={*{6}{c}},
                     }
    \SetCell[c=6]{c}    $a = 3$, $b = 3$        \\
    Cl1 & Cl2   & \SetCell[c=2]{c}    Cl3, Cl4
                        &       & \SetCell[c=2]{c}    Cl5, Cl6
                                        &       \\
        & aa    &   bb  &   cc  &   dd  &   ee  \\
    1   & \SetCell[r=9]{c} 10
                &   11  &   20  &   29  &   38  \\
    2   &       &   12  &   21  &   30  &   39  \\
    3   &       &   13  &   22  &   31  &   40  \\
    4   &       &   14  &   23  &   32  &   41  \\
    5   &       &   15  &   24  &   33  &   42  \\
    6   &       &   16  &   25  &   34  &   43  \\
    7   &       &   17  &   26  &   35  &   44  \\
    8   &       &   18  &   27  &   36  &   45  \\
    9   &       &   19  &   28  &   37  &   46  \\
    \end{tblr}
    \end{minipage}
\end{document}

在此处输入图片描述

答案2

\valign这里也可以使用原始函数:

\def\vcell#1{\hbox to2.5em{\lower.5em\vbox to2em{}\hss#1\unskip\hss}}
\def\bcell#1{\hrule \vss\vcell{#1}\vss}
\def\p #1/#2 {\vbox{\medskip\halign{\hfil##\hfil\cr #1\cr#2\cr}\smallskip}}
\def\l{\crcr\noalign{\vrule}}
\vbox{
\hbox{\valign{&\hrule\vcell{#}\cr\l
  \p Cl1/   & 1 & 2 & 3 \cr\l
  \p Cl2/aa & \multispan3  \bcell{4} \cr\l
  \p Cl2/bb & 5 & 6 & 7 \cr\l
  \p Cl4/cc & 8 & 9 & 10 \cr\l
  \p Cl5/dd & 11 & 12 & 13 \cr\l
  \p Cl6/ee & 14 & 15 & 16 \cr\l
}}
\hrule
}

请注意,此处的数据是按列逐列写入的,而不是按行逐行写入的。

答案3

第一个带有书本标签的表格命题(我认为垂直条永远不应该出现在表格中......)另一个带有表格演示的命题:

\documentclass{article}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{multirow}

\begin{document}
    \begin{minipage}[c]{0.5\textwidth}
        \centering
        \captionof{table}{abc}
        \begin{tabular}{cccccc}
            \toprule
                \multicolumn{6}{c}{{$a = 1$, $b = 1$}} \\
            \midrule          
                \makecell[c]{Cl1} & \makecell[c]{Cl2\\aa} & \multicolumn{2}{c}{\makecell[c]{Cl3, Cl4\\bb, cc}} & \multicolumn{2}{c}{\makecell[c]{Cl5, Cl6\\ dd, ee}} \\
            \midrule
            1 & \multirow{3}{*}{4} & 5 & 8 & 11 & 14  \\
            2 &  & 6 & 9 & 12 & 15 \\
            3 &  & 7 & 10 & 13 & 16 \\
            \hline          
        \end{tabular}
        \bigskip
        \captionof{table}{def}
        \begin{tabular}{|c|c|c|c|c|c|}
            \hline
            \multicolumn{6}{|c|}{{$a = 2$, $b = 2$}}                                                                     \\ \hline
            Cl1 &               Cl2                & \multicolumn{2}{|c|}{{Cl3, Cl4}} & \multicolumn{2}{|c|}{{Cl5, Cl6}} \\
                &                aa                & bb &             cc              & dd &             ee              \\ \hline
             1  & \multirow{5}{*}{6} & 7  &             12              & 17 &             22              \\ \cline{1-1}\cline{3-6}
             2  &                                  & 8  &             13              & 18 &             23              \\ \cline{1-1}\cline{3-6}
             3  &                                  & 9  &             14              & 19 &             24              \\ \cline{1-1}\cline{3-6}
             4  &                                  & 10 &             15              & 20 &             25              \\ \cline{1-1}\cline{3-6}
             5  &                                  & 11 &             16              & 21 &             26              \\ \hline
        \end{tabular}
    \end{minipage}
\end{document}

相关内容