Multirow and multicolumn in long table

multicolumnmultirow

any suggestion for this desired table

enter image description here

here my code

   \documentclass{article}

   \usepackage{booktabs}
   \usepackage{multirow}
   \usepackage[margin=20mm]{geometry}
   \begin{document}

     \begin{table}
     \begin{tabular}{lSSSSSSSS}
     \toprule
        \multirow{2}{*}{ Markets Models} &
        \multicolumn{2}{c}{HK – MEM(1,1)} &
        \multicolumn{2}{c}{IN- MEM(1,1)} &
        \multicolumn{2}{c}{KO- MEM(1,1)} &
         \multicolumn{2}{c}{MA- MEM(2,1)} \\
       & {Base} & {Selected} & {Base} & {Selected} & {Base} & {Selected}& {Base} & {Selected} 
  \\
    \midrule
        
Loglik & -3267.975 &-3265.314& -3447.357& -3434.800& -3696.633& -3694.599& -3032.638& -3029.500 \\

    LB(12) & 20.920& 13.805& 51.230& 20.545& 23.850& 13.335& 21.729& 15.733 \\
           & 0.052& 0.313& 0.000& 0.057& 0.021& 0.345& 0.041& 0.204 \\

    LBSQ(12)  & 20.212&  13.087&  18.497&  12.647&  15.899&  10.677&  14.488&  10.958\\
              & 0.063& 0.363& 0.101& 0.395& 0.196& 0.557& 0.271& 0.533\\
                        
                        
    $\hat{\Phi}$     &  & 5.61  &  & 3.71   &  & 6.51  &   &4.41 \\
    No spillovers  &  & 2.326 &  & 5.978 &  & 2.372&   & 3.785\\
    p-value         &  & (0.023) &  & (0.000) &  & (0.002)&   &  (0.000)\\
    
    \bottomrule
     \end{tabular}
    \end{table}

    \end{document}

my output :

enter image description here

Best Answer

  • your document example is not complete. Mised are:
    • loading package siunitx
    • definition of S column specifications
  • instead of tabular is better to use tabular* table and left to LaTeX that calculate tabcolsep:
\documentclass{article}
\usepackage[margin=20mm, showframe]{geometry}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\sisetup{
    input-open-uncertainty =,
    input-close-uncertainty=,
    table-align-text-pre=false,
    group-minimum-digits=4,
    group-separator = {,}
        }

\begin{document}

     \begin{table}
     \small
     \setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l
                             *{8}{S[table-format=-4.4]} @{}}
     \toprule
\multirow{2}{*}{Markets Models} 
    &   \multicolumn{2}{c}{HK – MEM(1,1)} 
        &   \multicolumn{2}{c}{IN- MEM(1,1)} 
            &   \multicolumn{2}{c}{KO- MEM(1,1)} 
                &   \multicolumn{2}{c}{MA- MEM(2,1)}        \\
    \cmidrule(lr){2-3}\cmidrule(lr){4-5}
    \cmidrule(lr){6-7}\cmidrule(lr){8-9}
    & {Base}    & {Selected}    & {Base}    & {Selected} 
    & {Base}    & {Selected}    & {Base}    & {Selected}    \\
    \midrule
Loglik 
    & -3267.975 &-3265.314      & -3447.357 & -3434.800
    & -3696.633 & -3694.599     & -3032.638 & -3029.500     \\
LB(12) 
    & 20.920    & 13.805        & 51.230    & 20.545
    & 23.850    & 13.335        & 21.729    & 15.733        \\
    & 0.052     & 0.313         & 0.000     & 0.057
    & 0.021     & 0.345         & 0.041     & 0.204         \\

LBSQ(12)  
    & 20.212    &  13.087       &  18.497   &  12.647
    & 15.899    &  10.677       &  14.488   &  10.958       \\
    & 0.063     & 0.363         & 0.101     & 0.395
    & 0.196     & 0.557         & 0.271     & 0.533         \\
$\hat{\Phi}$     
    &           & 5.61          &           & 3.71   
    &           & 6.51          &           & 4.41          \\
No spillovers  
    &           & 2.326         &           & 5.978 
    &           & 2.372         &           & 3.785         \\
p-value         
    &           & (0.023)       &           & (0.000)
    &           & (0.002)       &           & (0.000)      \\
    \bottomrule
\end{tabular*}
    \end{table}
\end{document}

enter image description here

Addendum:

In the case, that you will need a long table and that numbers in rows without name should be in parenthesis (I suspect this), and a bit better formation than you may consider the following solution (which use the tabularray package):

\documentclass{article}
\usepackage[margin=20mm]{geometry}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document

\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\sisetup{
    input-open-uncertainty =,
    input-close-uncertainty=,
    table-align-text-pre=false,
    group-minimum-digits=4,
    group-separator = {,}
        }
\SetTblrStyle{caption-tag}{font=\small\scshape}
\SetTblrStyle{caption-text}{font=\small\scshape}

\begin{document}
\lipsum[1-7]
\begin{longtblr}[
caption = {Model Diagnostic},
  label = {tab:MD}
                ]{rowhead = 2,
                  colsep  = {3pt},
                  colspec = {@{}l *{8}{X[c, si={table-format=-4.3{)}}]} @{}},
                  row{3-X}= {rowsep = 0pt},
                    rows  = {font=\small}
                 }
     \toprule
\SetCell[r=2]{c}    Markets Models 
    &   \SetCell[c=2]{c}    {{{HK – MEM(1,1)}}} 
        &   &   \SetCell[c=2]{c}    {{{IN -- MEM(1,1)}}} 
            &   &   \SetCell[c=2]{c}    {{{KO -- MEM(1,1)}}} 
                &   &   \SetCell[c=2]{c}    {{{MA -- MEM(2,1)}}}  \\
    \cmidrule[lr]{2-3}\cmidrule[lr]{4-5}
    \cmidrule[lr]{6-7}\cmidrule[lr]{8-9}
    & {{{Base}}}    & {{{Selected}}}    & {{{Base}}}    & {{{Selected}}} 
    & {{{Base}}}    & {{{Selected}}}    & {{{Base}}}    & {{{Selected}}}    \\
    \midrule
Loglik 
    & -3267.975     &-3265.314      & -3447.357 & -3434.800
    & -3696.633     & -3694.599     & -3032.638 & -3029.500     \\
    \addlinespace
LB(12) 
    & 20.920        & 13.805        & 51.230    & 20.545
    & 23.850        & 13.335        & 21.729    & 15.733        \\
    & (0.052)       & (0.313)       & (0.000)   & (0.057) 
    & (0.021)       & (0.345)       & (0.041)   & (0.204)       \\
    \addlinespace
LBSQ(12)  
    & 20.212        &  13.087       &  18.497   &  12.647
    & 15.899        &  10.677       &  14.488   &  10.958       \\
    & (0.063)       & (0.363)       & (0.101)   & (0.395)
    & (0.196)       & (0.557)       & (0.271)   & (0.533)       \\
    \addlinespace
$\hat{\Phi}$     
    &               & 5.61          &           & 3.71   
    &               & 6.51          &           & 4.41          \\
    \midrule[0.15pt, fg=gray]
No spillovers
    &               & 2.326         &           & 5.978
    &               & 2.372         &           & 3.785         \\
p-value
    &               & (0.023)       &           & (0.000)
    &               & (0.002)       &           & (0.000)      \\
    \midrule[2pt, fg=gray]
\SetCell[c=9]{c}    some text (as title for next table part)
    &   &   &   &   &   &   &   &                           \\
    \midrule
Loglik
    & -3267.975     &-3265.314      & -3447.357 & -3434.800
    & -3696.633     & -3694.599     & -3032.638 & -3029.500     \\
    \addlinespace
LB(12)
    & 20.920        & 13.805        & 51.230    & 20.545
    & 23.850        & 13.335        & 21.729    & 15.733        \\
    & (0.052)       & (0.313)       & (0.000)   & (0.057)
    & (0.021)       & (0.345)       & (0.041)   & (0.204)       \\
    \addlinespace
LBSQ(12)
    & 20.212        &  13.087       &  18.497   &  12.647
    & 15.899        &  10.677       &  14.488   &  10.958       \\
    & (0.063)       & (0.363)       & (0.101)   & (0.395)
    & (0.196)       & (0.557)       & (0.271)   & (0.533)       \\
    \addlinespace
$\hat{\Phi}$
    &               & 5.61          &           & 3.71
    &               & 6.51          &           & 4.41          \\
    \midrule[0.15pt, fg=gray]
No spillovers
    &               & 2.326         &           & 5.978
    &               & 2.372         &           & 3.785         \\
p-value
    &               & (0.023)       &           & (0.000)
    &               & (0.002)       &           & (0.000)      \\
    \bottomrule
\end{longtblr}
\end{document}

enter image description here

Related Question