1

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}
  \newcommand\tc[1]{\textcolor{blue}{#1}}

 \begin{document}
 \begin{table}[ht!]
 \footnotesize
  \setlength\tabcolsep{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.119\tc{***} &  2.372\tc{***} & 4.706\tc{***} & 2.668\tc{***} & 2.746\tc{***} & 
      3.410\tc{***} & 3.472\tc{***}& 3.470\tc{***}& 3.465\tc{***}\\
      & (1.58)&  (6.07)&  (4.27)&  (5.17)&  (5.07) \\   
\addlinespace
      NPL($-1$) & 0.520\tc{***} &  \\
      & (18.16)     &  \\  
\addlinespace
 \emph{Specialization}  \\
 Log (Loans-to-Assets) & 0.505\tc{***}\\ 
                  & (1.422)    \\  
\addlinespace
\emph{Credit Quality} \\
 Log (Loan loss provi-       & 0.361\tc{***}  & \\
      \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.039\tc{**} & -0.028\tc{**} & -0.109\tc{***}\\
              & (2.75)         & (-2.31)        & (-3.51) \\ 
   \addlinespace
       \hfill Mov(3) & & & & -0.061\tc{***}  & & -0.021\tc{**}  & \\
             & & & & (-4.60)          & & (-1.03)         & \\
    \addlinespace
    \hfill Mov(4) & & & & & -0.044\tc{**} & & -0.045\tc{***}\\
             & & & & & (1.65)         & & (-3.42)\\
 \addlinespace
   Log (Inflation)       & -0.0338\tc{***} & \\
                  & (-0.406)         & \\  
\addlinespace
\bottomrule
\end{tabular*}
\end{table}
\end{document}
2
  • Which headers are you referring to specifically? "industry" and "services" or something else? Please clarify. Please also make your code compilable. Currently the d column type as well as the \mc command are undefined.
    – leandriis
    Aug 11 '20 at 18:39
  • Yes the industry and services headers !
    – haithem
    Aug 11 '20 at 18:51
1

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}
\newcommand\tc[1]{^{\textcolor{blue}{#1}}} % modified def.
%% new/missing instructions:
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}} 
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}

\begin{document}
\begin{table}[ht!]
\footnotesize
\setlength\tabcolsep{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.119\tc{***} & 2.372\tc{***} & 4.706\tc{***} 
            & 2.668\tc{***} & 2.746\tc{***} & 3.410\tc{***} 
            & 3.472\tc{***} & 3.470\tc{***} & 3.465\tc{***} \\
            & (1.58)&  (6.07)&  (4.27)&  (5.17)&  (5.07) \\   
  \addlinespace
  NPL($-1$) & 0.520\tc{***} &  \\
            & (18.16)       &  \\  
  \addlinespace
  \emph{Specialization} \\
  Log(Loans-to-Assets) & 0.505\tc{***}\\ 
                        & (1.422)    \\  
  \addlinespace
  \emph{Credit Quality} \\
  Log(Loan loss provi-       & 0.361\tc{***}  & \\
  \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\quad Mov(2) & -0.039\tc{**} & -0.028\tc{**} & -0.109\tc{***}\\
                    & (2.75)         & (-2.31)        & (-3.51) \\ 
  \addlinespace
  \phantom{GDP}\quad Mov(3) & & & & -0.061\tc{***}  & & -0.021\tc{**}  & \\
                            & & & & (-4.60)          & & (-1.03)       & \\
  \addlinespace
  \phantom{GDP}\quad Mov(4) & & & & & -0.044\tc{**} & & -0.045\tc{***}\\
                            & & & & & (1.65)        & & (-3.42)\\
  \addlinespace
  Log(Inflation)    & -0.0338\tc{***} & \\
                    & (-0.406)        & \\  
  %%%\addlinespace % not needed
  \bottomrule
  \end{tabular*}
\end{table}
\end{document}
1
  • Dear Mico, Thank you for sharing your expertise, I really appreciate it!
    – haithem
    Aug 11 '20 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.