如何给这个表格添加标题?

如何给这个表格添加标题?

我有以下表格。我想在上面添加标题和表格编号。但我没能做到。这是我的代码:

\begin{center}
\begin{tabular}{lr}
\toprule
\label{tab: first}
  & $Hawkish$\\
\midrule
budget balance & $-0.21$\\
rebuild fiscal buffer &  $-0.71$\\
fiscal consolidation &  $-0.93$\\
get their house in order & $-0.22$\\
avoid any procyclical bias & $-0.21$\\
expenditure restraint & $-0.75$\\
budget retrenchment & $-0.21$\\
no case for fiscal activism  & $-0.21$\\
debt sustainability & $-0.70$\\
deficit reduction & $-0.82$\\
structural adjustment & $-0.82$\\
\bottomrule
\end{tabular}
\begin{tabular}{lr}
\toprule
  & $Dovish$\\
\midrule
domestic demand & $0.75$\\
fiscal space & $0.84$\\
government expenditure & $0.53$\\
job creation & $0.18$\\
flexibility & $0.24$\\
automatic stabiliser & $0.51$\\
public investment & $0.91$\\
public sector & $0.54$\\
fiscal union & $0.68$\\
growth friendly & $0.71$\\
ease social hardship & $0.86$\\
\bottomrule
\end{tabular}
\end{center}

谁能帮我?

谢谢!

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs, caption}

\begin{document}

\begin{table}

\centering
    \caption{caption above table}
\begin{tabular}{lr}
\toprule
\label{tab: first}
  & $Hawkish$\\
\midrule
budget balance & $-0.21$\\
rebuild fiscal buffer &  $-0.71$\\
fiscal consolidation &  $-0.93$\\
get their house in order & $-0.22$\\
avoid any procyclical bias & $-0.21$\\
expenditure restraint & $-0.75$\\
budget retrenchment & $-0.21$\\
no case for fiscal activism  & $-0.21$\\
debt sustainability & $-0.70$\\
deficit reduction & $-0.82$\\
structural adjustment & $-0.82$\\
\bottomrule
\end{tabular}
\begin{tabular}{lr}
\toprule
  & $Dovish$\\
\midrule
domestic demand & $0.75$\\
fiscal space & $0.84$\\
government expenditure & $0.53$\\
job creation & $0.18$\\
flexibility & $0.24$\\
automatic stabiliser & $0.51$\\
public investment & $0.91$\\
public sector & $0.54$\\
fiscal union & $0.68$\\
growth friendly & $0.71$\\
ease social hardship & $0.86$\\
\bottomrule
\end{tabular}
\caption{caption below table}

\end{table}



\textbf{
or minipage environment if you dont want the table to float \\ [1cm] 
}


\begin{minipage}{\linewidth}
    \centering
    \captionof{table}{Table Title} \label{tab:title} 
\begin{tabular}{lr}
    \toprule
    & $Dovish$\\
    \midrule
    domestic demand & $0.75$\\
    fiscal space & $0.84$\\
    government expenditure & $0.53$\\
    job creation & $0.18$\\
    flexibility & $0.24$\\
    automatic stabiliser & $0.51$\\
    public investment & $0.91$\\
    public sector & $0.54$\\
    fiscal union & $0.68$\\
    growth friendly & $0.71$\\
    ease social hardship & $0.86$\\
    \bottomrule
\end{tabular}\par
        \bigskip
        Should be a caption
    \end{minipage}
\end{document}

相关内容