如何使 table 适合页面宽度?

How to fit a table to the width of the page?

我正在尝试使用背面制作乳胶 table。我怎样才能让这个 table 显示在一页上?附上一张图片,展示了我的 table 目前的样子。

\documentclass{article}
\usepackage{booktabs}
\usepackage{dcolumn}
\begin{document}
\begin{table}[ht]
\caption{Summary Statistics and Sell in May Effect}
\centering
\begin{tabular}{c c c c c c c c c c}
\hline\hline 
 &  &  &  &  &  &  & t-Values of & t-Values of January\ [0.5ex]
  &   &   &  &  &  &  & Adjusted Sell & Dummy with\
    &  &  &  &  & & t-Values of Sell in & in May & Adjusted Sell\
      &  &  & Mean &  &  & May Dummy & Dummy with & in May Dummy\
     Country & Period & Observations & Return & Deviation & Alpha1 & (No January 
     Effect) & January Effect & in May Dummy\
\hline
1 & 50 & 837 & 970 \
2 & 47 & 877 & 230 \
3 & 31 & 25 & 415 \
4 & 35 & 144 & 2356 \
5 & 45 & 300 & 556 \ [1ex]
\hline
\end{tabular}
\label{table:nonlin} % is used to refer this table in the text
\end{table}
\end{document}

您可以使用像 tabularx 或新的 tabularray 这样的包,它们允许 table 自动调整到线宽。

但是你有太多的列,结果看起来很糟糕。所以在下面的示例中,我还更改了页面几何形状以获得更多 space.

\documentclass{article}

\usepackage{tabularray}
\usepackage[hmargin=1cm]{geometry}

\begin{document}

\begin{table}[ht]
\caption{Summary Statistics and Sell in May Effect}
\begin{tblr}{
  @{}ccccccX[c,valign=b]X[c,valign=b]X[c,valign=b]@{}
}
\hline
\hline
Country & 
Period  &  
Observations & 
Mean Return & 
Deviation & 
Alpha1 & 
t-Values of Sell in May Dummy (No January Effect) & 
t-Values of Adjusted Sell in May Dummy with January Effect & 
t-Values of January Dummy with Adjusted Sell in May Dummy\
\hline
1 & 50 & 837 & 970 \
2 & 47 & 877 & 230 \
3 & 31 & 25 & 415 \
4 & 35 & 144 & 2356 \
5 & 45 & 300 & 556\
\hline
\end{tblr}
\label{table:nonlin} % is used to refer this table in the text
\end{table}
\end{document}