I am using tabularx to fit the table to textwidth
\begin{table}[ht!]
\centering
\caption{Nice Title}
\scriptsize
\begin{threeparttable}[b]
\begin{tabularx}{\textwidth}{@{}l cccc cccc@{}}
\hline\hline
\addlinespace[2ex]
& \multicolumn{4}{c}{\textbf{Panel A: }} & \multicolumn{4}{c}{\textbf{Panel B: }} \\
\addlinespace[1ex]
\cmidrule(r){2-5} \cmidrule(l){6-9}
\addlinespace[1ex]
& Linear & KNN & G-Boost & MLP
& Linear & KNN & G-Boost & MLP \\
\addlinespace[1ex]
\hline
\addlinespace[1ex]
avg MAE & 0.201 & 0.019 & 0.042 & 0.057 & 0.179 & 0.181 & 0.056 & 0.059 \\
\addlinespace[1ex]
std MAE & (0.005) & (0.001) & (0.001) & (0.003) & (0.004) & (0.005) & (0.001) & (0.003) \\
\addlinespace[1ex]
avg MSE & 0.287 & 0.043 & 0.064 & 0.089 & 0.259 & 0.269 & 0.084 & 0.090 \\
\addlinespace[1ex]
std MSE & (0.009) & (0.005) & (0.002) & (0.008) & (0.008) & (0.008) & (0.002) & (0.004) \\
\addlinespace[1ex]
\hline
\end{tabularx}
\begin{tablenotes}[para,flushleft]
\linespread{1}\scriptsize
\item\hspace*{-\fontdimen2\font}Notes: Some Footnote here
\end{tablenotes}
\end{threeparttable}
\end{table}
Which gives me
Maybe what I am doing is not right, and I should just replace \begin{tabularx}{\textwidth}
with \begin{tabular}
which works fine, but somehow I was hoping to find a solution where Latex would just adjust the width of the columns to match textwidth.
Hope it is clear, and of course other feedback on bad code is welcome as well.
Update: If I use the X column type from tabular x it solves the problem of fitting the table to width, however the way it does not look nice.
Nor does it if I only stretch the first column. How to get this to look good?