I have been trying to reduce the space between the columns in a table that was exported directly from Stata.
The table is the following:
\begin{table}[H]
\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Regression\label{tab1}}
\begin{tabular*}{1.1\hsize}{@{\hskip\tabcolsep\extracolsep\fill}l*{4}{D{.}{.}{-1}}}
\toprule
I know I need to work with \tabcolsep
but I am not sure how to isolate it from that big piece of code I have already.
Following @leandriis feedback I replaced 1.1\hsize
with \textwidth
, but that does not seem to work:
what I had:
I want the columns to be closer together, as that way it is out of the margins of the rest of my work.
And if I include \textwidth
this is what I get:
My minimal working example as requested:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pdflscape}
\usepackage{graphicx}
\usepackage{indentfirst}
\usepackage{geometry}
\usepackage{dcolumn}
\usepackage{wrapfig}
\usepackage{booktabs}
\usepackage{placeins}
\usepackage{float}
\restylefloat{table}
\graphicspath{ {./mypath/} }
\begin{document}
\setlength{\parindent}{3em}
\setlength{\parskip}{1em}
\FloatBarrier
\begin{small}
\input{\begin{table}[H]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Regression with country and year dummies\label{tab1}}
\begin{tabular*}{1.1\hsize}{@{\hskip\tabcolsep\extracolsep\fill}l*{4}{D{.}{.}{-1}}}
\toprule
&\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
&\multicolumn{1}{c}{Group 1}&\multicolumn{1}{c}{Group 2}&\multicolumn{1}{c}{Group 3}&\multicolumn{1}{c}{Group 4}\\
\midrule
propyes1 & 305.1\sym{***}& & & \\
& (205.46) & & & \\
\addlinespace
gdppc & -0.0000193\sym{***}& 0.00000260\sym{*} & -0.0000174\sym{***}& -0.0000147\sym{***}\\
& (-18.19) & (2.38) & (-16.38) & (-13.72) \\
\addlinespace
propyes2 & & 17.19\sym{***}& & \\
& & (75.74) & & \\
\addlinespace
propyes3 & & & 9.964\sym{***}& \\
& & & (40.51) & \\
\addlinespace
propyes4 & & & & -6.050\sym{***}\\
& & & & (-35.42) \\
\addlinespace
Constant & 13.66\sym{***}& 58.99\sym{***}& 60.07\sym{***}& 64.76\sym{***}\\
& (84.14) & (541.52) & (478.00) & (667.77) \\
\midrule
Observations & 386364 & 386364 & 386364 & 386364 \\
\bottomrule
\multicolumn{5}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{5}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
\end{tabular*}
\end{table}}
\end{small}
\FloatBarrier
\end{document}
\begin{table}
,\setlength{\tabcolsep}{3pt}
(the default is 6pt).1.1\hsize
with\textwidth
. With this adjustment, your table fits onto the page and at the same time, the distance between the columns is reduced. If you want your table to be as wide as it naturally is, you could give\begin{tabular}{l*{4}{D{.}{.}{-1}}}
a try.tabular*
in combination with\extracolsep
, explicitly reducing the value of\tabcolsep
won't make much of a difference here.\tabcolstep
that appears in the middle of my code just like that? Because if I add it without touching anything else everything remains intact\begin{tabular*}{1.1\hsize}
is to force the column spacing to be larger than normal (and force the table to be wider than the page)