TransWikia.com

headers of multirow multicolum large table

TeX - LaTeX Asked on May 12, 2021

How do I create these headers:

OF

MY code:

   documentclass{article}
  usepackage[T1]{fontenc}
  usepackage[margin=2.5cm,a4paper]{geometry} 
  usepackage{booktabs}
  usepackage{siunitx}
  usepackage[skip=1ex]{caption}
  usepackage{xcolor}
  newcommandtc[1]{textcolor{blue}{#1}}

 begin{document}
 begin{table}[ht!]
 footnotesize
  setlengthtabcolsep{0pt} 
  begin{tabular*}{textwidth}{@{extracolsep{fill}} l *{9}{d{2.5}} }
  toprule
   Variables & mc{AGR&FISH} & mc{CONST} & mc{ENRG} 
      & mc{MANF} & mc{MIN} & mc{TRSM} & mc{TRANS}& mc{TRADE}& mc{HH}
midrule
  Constant  & 4.119tc{***} &  2.372tc{***} & 4.706tc{***} & 2.668tc{***} & 2.746tc{***} & 
      3.410tc{***} & 3.472tc{***}& 3.470tc{***}& 3.465tc{***}
      & (1.58)&  (6.07)&  (4.27)&  (5.17)&  (5.07)    
addlinespace
      NPL($-1$) & 0.520tc{***} &  
      & (18.16)     &    
addlinespace
 emph{Specialization}  
 Log (Loans-to-Assets) & 0.505tc{***} 
                  & (1.422)      
addlinespace
emph{Credit Quality} 
 Log (Loan loss provi-       & 0.361tc{***}  & 
      quad sions to total loans) & (11.47)         &   
  addlinespace
     Log (Diversification) & -0.022 & 
                  & (-0.24)&   
   addlinespace
   emph{Profitability}    & 
    Log (Return on Assets)  & -0.091^tc{***} &    
                    & (-2.26)         & 
    addlinespace
   GDP hfill Mov(2) & -0.039tc{**} & -0.028tc{**} & -0.109tc{***}
              & (2.75)         & (-2.31)        & (-3.51)  
   addlinespace
       hfill Mov(3) & & & & -0.061tc{***}  & & -0.021tc{**}  & 
             & & & & (-4.60)          & & (-1.03)         & 
    addlinespace
    hfill Mov(4) & & & & & -0.044tc{**} & & -0.045tc{***}
             & & & & & (1.65)         & & (-3.42)
 addlinespace
   Log (Inflation)       & -0.0338tc{***} & 
                  & (-0.406)         &   
addlinespace
bottomrule
end{tabular*}
end{table}
end{document}

One Answer

In addition to modifying the header material to meet your formatting requirements, I had to add a number of instructions and modify the tc macro in order to get your code to compile.

enter image description here

documentclass{article}
usepackage[T1]{fontenc}
usepackage[margin=2.5cm,a4paper]{geometry} 
usepackage{booktabs}
%usepackage{siunitx} % not needed for this MWE
%usepackage[skip=1ex]{caption} % not needed for this MWE
usepackage{xcolor}
newcommandtc[1]{^{textcolor{blue}{#1}}} % modified def.
%% new/missing instructions:
usepackage{dcolumn}
newcolumntype{d}[1]{D..{#1}} 
newcommandmc[1]{multicolumn{1}{c}{#1}}

begin{document}
begin{table}[ht!]
footnotesize
setlengthtabcolsep{0pt} 
  begin{tabular*}{textwidth}{@{extracolsep{fill}} 
      l *{8}{d{2.5}} d{1.6} }
  toprule
  Variables 
       & mc{AGR&FISH} 
       & multicolumn{4}{c}{INDUSTRY} 
       & multicolumn{3}{c}{SERVICES}
       & mc{HH} 
  cmidrule{3-6} cmidrule{7-9}
     && mc{CONSTR} & mc{ENRG} & mc{MANF} & mc{MIN} &
        mc{TRSM} & mc{TRANS} & mc{TRADE} 
  midrule
  Constant  & 4.119tc{***} & 2.372tc{***} & 4.706tc{***} 
            & 2.668tc{***} & 2.746tc{***} & 3.410tc{***} 
            & 3.472tc{***} & 3.470tc{***} & 3.465tc{***} 
            & (1.58)&  (6.07)&  (4.27)&  (5.17)&  (5.07)    
  addlinespace
  NPL($-1$) & 0.520tc{***} &  
            & (18.16)       &    
  addlinespace
  emph{Specialization} 
  Log(Loans-to-Assets) & 0.505tc{***} 
                        & (1.422)      
  addlinespace
  emph{Credit Quality} 
  Log(Loan loss provi-       & 0.361tc{***}  & 
  quad sions to total loans) & (11.47)         &   
  addlinespace
  Log(Diversification)  & -0.022 & 
                         & (-0.24)&   
  addlinespace
  emph{Profitability} 
  Log(Return on Assets) & -0.091tc{***} &    
                         & (-2.26)         & 
  addlinespace
  GDPquad Mov(2) & -0.039tc{**} & -0.028tc{**} & -0.109tc{***}
                    & (2.75)         & (-2.31)        & (-3.51)  
  addlinespace
  phantom{GDP}quad Mov(3) & & & & -0.061tc{***}  & & -0.021tc{**}  & 
                            & & & & (-4.60)          & & (-1.03)       & 
  addlinespace
  phantom{GDP}quad Mov(4) & & & & & -0.044tc{**} & & -0.045tc{***}
                            & & & & & (1.65)        & & (-3.42)
  addlinespace
  Log(Inflation)    & -0.0338tc{***} & 
                    & (-0.406)        &   
  %%%addlinespace % not needed
  bottomrule
  end{tabular*}
end{table}
end{document}

Correct answer by Mico on May 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP