线条不连续且空间不均匀的表格

线条不连续且空间不均匀的表格

我正在使用“Overleaf”,但在定义表格时遇到了麻烦。我想要一个表格,其中的行连续且列在垂直和水平方向上等距分布。
代码如下:

    \usepackage{tabularx,booktabs}
    \begin{document}
    \begin{table}[h!]
     \begin{center}
    \bigskip
    \begin{tabular}{|*{8}{p{11mm}|}}
        

       \toprule
         \multicolumn{1}{c}{Method} & &
     \multicolumn{2}{c|}{I assimilation} & \multicolumn{2}{c|}{II assimilation} & \multicolumn{2}{c|}{III assimilation}  \\
            
            \cmidrule(lr){3-4} \cmidrule(lr){5-6}\cmidrule(lr){7-8}
          \multicolumn{1}{c}{} & & \multicolumn{1}{c}{\textbf{PF}} & \textbf{PN}&\textbf{PF} & \textbf{PN}&\textbf{PF} & \textbf{PN} \\
            \cline{1-8}
         
        {Open Loop} &{\textbf{OF}} & {?} & {?} & {?} & {?} & {?} & {?} \\
        
     &{\textbf{ON}}& {?} & {?} & {?} & {?} &{?} &{?} \\
        \cline{2-8}
        {TPF} &{\textbf{OF}} & {?} & {?} & {?} & {?} & {?}& {?}\\ 
        
         &{\textbf{ON}}& {?} &{?} & {?} & {?} & {?} & {?} \\ 
        
        
        \end{tabular}
          \bigskip
 \end{center}
\end{table}
\end{document}

答案1

使用tabularay包装很简单:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
\begin{table}[ht]
     \centering
\begin{tblr}{vlines,
             colspec={*{8}{X[c]}},
             column{2}={font=\bfseries},
                row{2}={font=\bfseries},
             }
    \toprule
\SetCell[r=2, c=2]{c} Method 
    &   &   \SetCell[c=2]{c} I assimilation 
            &   &   \SetCell[c=2]{c} II assimilation 
                    &   &   \SetCell[c=2]{c} III assimilation   
                            &                                   \\
    \midrule
     &          & PF    & PN    & PF    & PN    & PF    &   PN  \\
    \midrule
\SetCell[r=2]{c} {Open\\ Loop} 
    & OF    & ? & ? & ? & ? & ? & ?     \\
    & ON    & ? & ? & ? & ? & ? & ?     \\
    \cmidrule{2-8}
\SetCell[r=2]{c} TPF
    & OF    & ? & ? & ? & ? & ? & ?     \\
    & ON    & ? & ? & ? & ? & ? & ?     \\
    \bottomrule
    \end{tblr}
\end{table}
\end{document}

表格阵列表

答案2

在此处输入图片描述

\documentclass{article}
 \usepackage{tabularx,booktabs,multirow}
\begin{document}
    \begin{table}[h!]
            \begin{tabular}{|*{8}{p{11mm}|}}
                \hline
                \multicolumn{1}{|c}{Method} 
                    &
                        &\multicolumn{2}{c|}{I assimilation} 
                            & \multicolumn{2}{c|}{II assimilation} 
                                & \multicolumn{2}{c|}{III assimilation}  \\
                \cline{3-4} \cline{5-6}\cline{7-8}
                \multicolumn{1}{|c}{} 
                    & 
                        & \multicolumn{1}{c}{\textbf{PF}} 
                            & \textbf{PN}
                                &\textbf{PF} 
                                    & \textbf{PN}
                                        &\textbf{PF} 
                                            & \textbf{PN} \\
                \hline              
                {Open Loop} 
                    &{\textbf{OF}} 
                        & {?} 
                            & {?} 
                                & {?} 
                                    & {?} 
                                        & {?} 
                                            & {?} \\
                
                    &{\textbf{ON}}
                        & {?} 
                            & {?} 
                                & {?} 
                                    & {?} 
                                        &{?} 
                                            &{?} \\
                \cline{2-8}
                {TPF} 
                    &{\textbf{OF}} 
                        & {?} 
                            & {?} 
                                & {?} 
                                    & {?} 
                                        & {?}
                                            & {?}\\ 
                
                    &{\textbf{ON}}
                        & {?} 
                            &{?} 
                                & {?} 
                                    & {?} 
                                        & {?} 
                                            & {?} \\ 
                \hline
                
            \end{tabular}

    \end{table}

\texttt{OR with booktabs and multirow}  

\begin{table}[h!]
    \begin{tabular}{*{8}{p{11mm}}}
        \toprule
        \multicolumn{1}{c}{Method} 
        &
        &\multicolumn{2}{c}{I assimilation} 
        & \multicolumn{2}{c}{II assimilation} 
        & \multicolumn{2}{c}{III assimilation}  \\
        \cmidrule(lr){3-4} \cmidrule(lr){5-6}\cmidrule(lr){7-8}
        \multicolumn{1}{c}{} 
        & 
        & \multicolumn{1}{c}{\textbf{PF}} 
        & \textbf{PN}
        &\textbf{PF} 
        & \textbf{PN}
        &\textbf{PF} 
        & \textbf{PN} \\
\cmidrule(lr){1-8}
        {Open} 
        &{\textbf{OF}} 
        & {?} 
        & {?} 
        & {?} 
        & {?} 
        & {?} 
        & {?} \\
        {Loop}
        &{\textbf{ON}}
        & {?} 
        & {?} 
        & {?} 
        & {?} 
        &{?} 
        &{?} \\
        \cmidrule(lr){2-8}
    \multirow{2}{*}{TPF} 
        &{\textbf{OF}} 
        & {?} 
        & {?} 
        & {?} 
        & {?} 
        & {?}
        & {?}\\ 
        
        &{\textbf{ON}}
        & {?} 
        &{?} 
        & {?} 
        & {?} 
        & {?} 
        & {?} \\ 
        \bottomrule
        
    \end{tabular}
    
\end{table}


\end{document}

相关内容