Is there a way to get page-width tables by slightly revising the code below generated from Stargazer?
The table generated from the code is longer than the page-width. Is there a way to make the table automatically fit the page-width ? By automatically, I mean I don't need to manually set a specific value for the column separate width, or column width, or other width.
\documentclass{article}
\usepackage{dcolumn}
\begin{document}
\begin{table}[!htbp] \centering
\caption{Table for test}
\label{}
\small
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} }
\[-1.8ex]\hline
\hline \[-1.8ex]
\[-1.8ex] & \multicolumn{1}{c}{Gap in 1M} & \multicolumn{1}{c}{Gap in 3M} & \multicolumn{1}{c}{Gap in 6M} & \multicolumn{1}{c}{Gap in 9M} & \multicolumn{1}{c}{Gap in 1Y} \
\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)} & \multicolumn{1}{c}{(4)} & \multicolumn{1}{c}{(5)}\
\hline \[-1.8ex]
Level & -1.521^{*} & -1.414^{} & -1.186^{} & -1.027^{} & -1.348^{} \
& (0.034) & (0.043) & (0.058) & (0.071) & (0.108) \
& & & & & \
Spread (10Y&3M) & -0.711^{} & -0.614^{} & -0.405^{} & -0.203^{} & 0.635^{} \
& (0.024) & (0.031) & (0.043) & (0.053) & (0.086) \
& & & & & \
Constant & 8.265^{} & 7.821^{} & 6.861^{} & 6.082^{} & 5.169^{**} \
& (0.070) & (0.084) & (0.107) & (0.120) & (0.136) \
& & & & & \
\hline \[-1.8ex]
Observations & \multicolumn{1}{c}{2,230} & \multicolumn{1}{c}{2,209} & \multicolumn{1}{c}{2,168} & \multicolumn{1}{c}{2,126} & \multicolumn{1}{c}{2,001} \
R$^{2}$ & \multicolumn{1}{c}{0.760} & \multicolumn{1}{c}{0.644} & \multicolumn{1}{c}{0.417} & \multicolumn{1}{c}{0.256} & \multicolumn{1}{c}{0.100} \
Adjusted R$^{2}$ & \multicolumn{1}{c}{0.760} & \multicolumn{1}{c}{0.644} & \multicolumn{1}{c}{0.417} & \multicolumn{1}{c}{0.255} & \multicolumn{1}{c}{0.099} \
\hline
\hline \[-1.8ex]
\end{tabular}
\end{table}
\end{document}
I found the solutions, such as using \resizebox, but the scales of the table are changed, which is not favourable.
Is there a way to get a page-width table from the code with limited changes in the code, hopefully? Thanks.




dcolumnpackage to defineDand guess a document size in which to fit the table, your example makes! Extra alignment tab has been changed to \cr.so no real output. Please provide an error free example that makes a table to be resized – David Carlisle Dec 21 '22 at 12:14Spread (10Y\&3M)with a literal&there? – David Carlisle Dec 21 '22 at 12:29\&fix to your table but it easily fits, what do you want to change? Or are you on a smaller page? Please edit the example – David Carlisle Dec 21 '22 at 12:33\begin{tabular*}{\textwidth}{@{\extracolsep{80pt}}lD{.}{.}{-3} } .... \end{tabular*}– Simon Dispa Dec 21 '22 at 16:46