使表格水平填充整个页面

使表格水平填充整个页面

我正在尝试将表格填满整个页面(水平)。我有下表:

\begin{table}\caption{Descriptive statistics of variables}\label{Statistics of all countries}
 \toprule
\small
\begin{tabularx}{\textwidth}{@{}LllllllllL@{}}
 & \multicolumn{4}{c}{Interest rate (basis points)} & \multicolumn{4}{c}{Debt-to-GDP (\%)} & \\
    Countries & $\mu$ & Max &  Min & $\sigma$ & $\mu$ & Max & Min & $\sigma$ \\
    \cmidrule(r){1-1}
      \cmidrule(lr){2-5}
\cmidrule(lr){6-9}
    Austria & 300.19 & 544.98 & -78.17 & 174.18 & 73.34 & 85.90 & 65.00 & 6.25  \\
    Belgium &  299.77 & 573.61 & -41.65 & 176.12 & 102.99 & 117.40 & 87.3 & 7.40 \\
    Finland &  258.71 & 533.34 & -241.38 & 186.23 & 44.19 & 64.20 & 28.70 & 10.54\\

    \cmidrule(r){1-1}
      \cmidrule(lr){2-5}
        \cmidrule(lr){6-9}
 Full sample & 720.47 & 3816.33 & 38.62 & 833.42 & 1.66 & 21.45 & 0.00 & 2.83
 \\
\end{tabularx}
\bottomrule
\addlinespace
\captionsetup{width=\textwidth}
\caption*{\textit{Descriptive statistics of all countries over the years 2000 until 2020 Q2 , excluding the crisis. The mean, maximum, minimum and standard deviation is given.}  }
\end{table}

我故意省略了多行。我尝试使用 \textwidth 填充页面,但没有效果。

答案1

不幸的是,并不完全清楚,你的表格应该是什么样的:

  • 定义了 11 列,但只使用了 9 列
  • 桌子线不能位于外部tabularx环境(或任何其他环境)
  • 我将使用包S中定义的siunitx数字列,这些数字以小数点对齐

清理代码片段后,带有表格的可能 MWE (最小工作示例) 可以是:

\documentclass{article}
\usepackage[skip=1ex,
            font=small, 
            labelfont=bf]{caption}
\usepackage{booktabs, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\NewExpandableDocumentCommand\mcx{O{1}m}{\multicolumn{#1}{C}{#2}}
\usepackage{siunitx}

\begin{document}
    \begin{table}
\caption{Descriptive statistics of variables}
\label{Statistics of all countries}
    \setlength\tabcolsep{3pt}
\begin{tabularx}{\textwidth}{ l 
                     S[table-format= 3.2]
                     S[table-format= 4.2]
                     S[table-format=-3.2]
                *{3}{S[table-format= 3.2]} 
                *{2}{S[table-format= 2.2]}
                             }
    \toprule
    & \multicolumn{4}{c}{Interest rate (basis points)} 
        & \multicolumn{4}{c}{Debt-to-GDP (\%)}              \\
    \cmidrule(l){2-5}
    \cmidrule(l){6-9}
Countries   & \mcx{$\mu$} & \mcx{Max} & \mcx{Min} & \mcx{$\sigma$}
            & \mcx{$\mu$} & \mcx{Max} & \mcx{Min} & \mcx{$\sigma$}\\
    \hline
Austria     & 300.19      & 544.98    &  -78.17     & 174.18 
            &  73.34      & 85.90     &   65.00     & 6.25      \\
Belgium     & 299.77      & 573.61    &  -41.65     & 176.12 
            & 102.99      & 117.40    &   87.3      & 7.40      \\
Finland     & 258.71      & 533.34    & -241.38     & 186.23 
            & 44.19       & 64.20     &   28.70     & 10.54     \\
    \cmidrule(r){1-1}
    \cmidrule(l){2-5}
    \cmidrule(l){6-9}
Full sample & 720.47      & 3816.33   & 38.62     & 833.42 
            & 1.66        & 21.45     & 0.00      & 2.83      \\
    \bottomrule
\end{tabularx}
    \captionsetup{font={small, it}}
\caption*{Descriptive statistics of all countries over the years 2000 until 2020 Q2 , excluding the crisis. The mean, maximum, minimum and standard deviation is given.}
    \end{table}
\end{document}

在此处输入图片描述

相关内容