我如何创建这些标题:
我的代码:
\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}
答案1
除了修改标题材料以满足您的格式要求之外,我还必须添加一些指令并修改宏\tc
以便编译您的代码。
\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}