如何制作此表

如何制作此表

我想将这个表格制成表格,但我的代码有些问题。如何以良好的方式重新编码这个表格?

这是我的代码:

\begin{table}[th]
\centering \scriptsize
\caption{Group A.}\label{group}
\begin{tabular}{c c| c |c |c|c|c|c|}
\cline{3-8}
 &&\multicolumn{3}{c|}{AA}& \multicolumn{3}{c|}{BB} %& 
 \bigstrut \\ 
               % & & & &\\ 
                 \cline{3-8} 
 &&  \multirow{1}{*}{1} & \multicolumn{1}{l|}{ \multirow{1}{*}{2} }& \multicolumn{1}{l|}{ \multirow{1}{*}{3} }&  \multirow{1}{*}{1} & \multicolumn{1}{l|}{ \multirow{1}{*}{2} }& \multicolumn{1}{l|}{ \multirow{1}{*}{3} }
  \bigstrut \\  \hline    
\multicolumn{2}{ |c|  }{Group A}  &&&&\\ 
& &LL  &LL &LL&LL&LL&LL  %\bigstrut 
\\  \hline 
 \multicolumn{1}{ |c|  }{\multirow{3}{*}{Group B} } &&&&\\ 
\multicolumn{1}{ |c |}{}      & YY & LL&LL  &LL &LL&LL&LL
\\
\cline{2-8} 
& \multicolumn{1}{ |c|  }{\multirow{2}{*}{ZZ} } &&&&\\ 
 &\multicolumn{1}{ |c |}{}     &  LL &LL &LL&LL&
\\
\cline{1-8} 

\multicolumn{2}{ |c|  }{Group A}  &\multicolumn{3}{ |c|  }{Group A}&\multicolumn{3}{ |c|  }{Group A}\\ 
&   %\bigstrut 
\\  \hline 

%\bigstrut \\ 
 %\hline


\end{tabular}
\end{table}

在此处输入图片描述

答案1

我猜您正在寻找下表:

在此处输入图片描述

\documentclass{article}
\usepackage{makecell, multirow}

\begin{document}
    \begin{table}[th]
\setcellgapes{3pt}
\makegapedcells
    \centering% \scriptsize
    \caption{Group A.}\label{group}
\begin{tabular}{|*{8}{c|}}
    \cline{3-8}
\multicolumn{2}{c|}{}
         &   \multicolumn{3}{c|}{AA}
                        & \multicolumn{3}{c|}{BB}       \\
    \cline{3-8}
\multicolumn{2}{c|}{}
         & 1  & 2  & 3  & 1  & 2  &   3 \\
    \hline
\multicolumn{2}{|c|}{Group A}
         & LL & LL & LL & LL & LL & LL  \\
    \hline
\multirow{3}{*}{Group B}
    & YY & LL & LL & LL & LL & LL & LL  \\
    \cline{2-8}
    & ZZ &    &    &    &    &    &     \\
    \cline{2-8}
    &    & LL & LL & LL & LL &    &     \\
    \cline{1-8}
\multicolumn{2}{|c|}{Group A}
         &  \multicolumn{3}{c|}{Group A}
                  & \multicolumn{3}{c|}{Group A}                   \\
    \hline
\end{tabular}
\end{table}
\end{document}

但我可能错了,因为您的 MWE 和表格图像都不清楚。

答案2

表格非常适合卡路里

\documentclass{article}
\usepackage{cals, caption}

\let\nc=\nullcell                     % CALS Shortcuts
\let\sc=\spancontent


\begin{document}

\begin{table}[th]
\caption{Group A.}\label{group}
\begin{calstable}[c]  % Centred calstable

% Calculate the column width
\colwidths{{\dimexpr(\columnwidth)/9\relax}
            {\dimexpr(\columnwidth)/9\relax}
            {\dimexpr(\columnwidth)/9\relax}
            {\dimexpr(\columnwidth)/9\relax}
            {\dimexpr(\columnwidth)/9\relax}    
            {\dimexpr(\columnwidth)/9\relax}
            {\dimexpr(\columnwidth)/9\relax}
            {\dimexpr(\columnwidth)/9\relax}
            {\dimexpr(\columnwidth)/9\relax}    
    }

% Nine columns each 1/9 column width

% Set up the tabular
\makeatletter
\def\cals@framers@width{0.4pt}   % Outside frame rules
\def\cals@framecs@width{0,4pt}
\def\cals@bodyrs@width{0.4pt}    % Rule between header and tabular body
\def\cals@cs@width{0.4pt}        % Inside vertical rules
\def\cals@rs@width{0.4pt}        % Inside horizontal rules

\def\lb{\ifx\cals@borderL\relax             % Left border switch (off-on)
    \def\cals@borderL{0pt}
\else \let\cals@borderL\relax\fi}

\def\tb{\ifx\cals@borderT\relax             % Top border switch (off-on)
    \def\cals@borderT{0pt}
\else \let\cals@borderT\relax\fi}


\def\lp{\ifdim\cals@paddingL=0.0pt\relax    % Left padding switch (off-on)
    \cals@setpadding{Ag}
\else \setlength{\cals@paddingL}{0pt}\fi}

\def\rp{\ifdim\cals@paddingR=0.0pt\relax    % Right padding switch (off-on)
    \cals@setpadding{Ag}
\else \setlength{\cals@paddingR}{0pt}\fi}

%% Tabular head & body
% R1H1
\thead{%           The first row are heading and vill be repeated on every page
\brow
    \tb\lb\nc{lt}
    \nc{t}
    \nc{rt}\lb\tb
    \nc{ltb}
    \nc{tb}
    \alignC\nc{rtb}\sc{AA}
    \nc{ltb}
    \nc{tb}
    \alignC\nc{rtb}\sc{BB}
\erow
}
\tfoot{\lastrule\nointerlineskip
\strut\par}
%R2B1
\brow
    \lb\nc{lb}
    \nc{b}
    \nc{rb}\sc{}\lb
    \cell{1}
    \cell{2}
    \cell{3}
    \cell{1}
    \cell{2}
    \cell{3}
\erow
%R3B2
\brow
    \nc{ltb}
    \nc{tb}
    \alignC\nc{rtb}\sc{Group A}
    \cell{LL}
    \cell{LL}
    \cell{LL}
    \cell{LL}
    \cell{LL}
    \cell{LL}
\erow
%R4B3
\brow
    \nc{lt}
    \nc{rt}
    \cell{yy}
    \cell{LL}
    \cell{LL}
    \cell{LL}
    \cell{LL}
    \cell{LL}
    \cell{LL}
\erow
%R5B4
\brow
    \nc{l}
    \nc{r}
    \cell{ZZ}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
\erow
%R6B5
\brow
    \nc{lb}
    \nc{rb}\sc{\vfil Group B}
    \cell{}
    \cell{LL}
    \cell{LL}
    \cell{LL}
    \cell{LL}
    \cell{}
    \cell{}
\erow
%R7B6
\brow
    \nc{ltb}
    \nc{tb}
    \alignC\nc{rtb}\sc{\vfil Group A}
    \nc{ltb}
    \nc{tb}
    \alignC\nc{rtb}\sc{\vfil Group A}
    \nc{ltb}
    \nc{tb}
    \alignC\nc{rtb}\sc{\vfil Group A}
\erow
\makeatletter
\end{calstable}\par
\end{table}
\end{document}

在此处输入图片描述

答案3

\documentclass{article}
\usepackage{makecell, multirow}

\begin{document}
    \begin{table}[th]
\setcellgapes{3pt}
\makegapedcells
    \centering% \scriptsize
    \caption{Group A.}\label{group}
\begin{tabular}{|*{8}{c|}}
    \cline{3-8}
\multicolumn{2}{c|}{}
         &   \multicolumn{3}{c|}{AA}
                        & \multicolumn{3}{c|}{BB}       \\
    \cline{3-8}
\multicolumn{2}{c|}{}
         & 1  & 2  & 3  & 1  & 2  &   3 \\
    \hline
%Group A
\multicolumn{2}{|c|}{Group A}
     & LL & LL & LL & LL & LL &         \\
    \hline
\multirow{3}{*}{Group B}
    & YY & LL & LL & LL & LL & LL & LL  \\
    \cline{2-8}
    & ZZ &    &    &    &    &    &     \\
    \cline{2-8}
    &    & LL & LL & LL & LL &    &     \\
    \cline{1-8}
\multicolumn{2}{|c|}{Group A}
         &  \multicolumn{3}{c|}{Group A}
                  & \multicolumn{3}{c|}{Group A}                   \\
    \hline
\end{tabular}
\end{table}
\end{document}

这个代码正是我需要的。谢谢大家!

相关内容