Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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}

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading