Im trying to create a latex table using overleaf. How can I fit this table to be shown on one page? Attached is a picture that shows how my table is currently looking like.
\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}
[Current table][1]
![1]: https://i.stack.imgur.com/HFmlu.png
>Solution :
You could use packages like tabularx or the new tabularray which allow the table to automatically adjust to the linewidth.
However you have sooooooooooo many columns that the result will look horrible. So in the example below, I also change the page geometry to get more space and use a smaller font.
\documentclass{article}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{tabularray}
\usepackage[hmargin=1cm]{geometry}
\begin{document}
\begin{table}[ht]
\caption{Summary Statistics and Sell in May Effect}
\centering
\small
\begin{tblr}{ccccccX[c]X[c]X[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{tblr}
\label{table:nonlin} % is used to refer this table in the text
\end{table}
\end{document}
