# problems with tables in latex

I am writing some tables in latex. My MWE is:

\documentclass{article}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{longtable}
\usepackage[labelfont=bf]{caption}
\usepackage[utf8]{inputenc}
\usepackage{caption, booktabs, makecell, siunitx}
\usepackage{eqparbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\usepackage[referable,para]{threeparttablex}
\usepackage[textheight=27cm, textwidth=15cm]{geometry}
\usepackage{multirow}
\usepackage{pdflscape}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***,
table-number-alignment =center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}

\begin{document}

\begin{sidewaystable}[htbp]\centering\normalsize{\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}
\caption{Baseline model \label{table3}}
\begin{tabular}{l*{5}{c}}
\hline\hline
&\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}&\multicolumn{1}{c}{(5)}\\
\hline
lwlnyw           &.984\sym{***}&        .674\sym{***}&                     &        .519\sym{***}&        .957\sym{***}\\
& (.007)            &      (.043)         &                     &      (.128)         &      (.013)         \\
pc                 & -.029\sym{**} &       -.045\sym{***}&       -.033\sym{***}&       -.103\sym{***}&       -.107\sym{***}\\
& (.015)             &      (.013)         &      (.013)         &      (.039)         &      (.036)         \\
pc2               & .003\sym{**} & .004\sym{***}&        .003\sym{***}&        .010\sym{***}&        .011\sym{***}\\
&      (.001)       &      (.001)         &      (.001)         &      (.004)         &      (.003)         \\
lnsnda2         &                     &                     &                     &                     &                     \\
&                     &                     &                     &                     &                     \\
\hline
Observations        &         681         &         681         &         681         &         553         &         681         \\
N. of Observations  &                     &         119         &         119         &         119         &         119         \\
Overall-R$^2$       &                     &        .988         &                     &                     &                     \\
R$^2$               &        .989         &        .723         &                     &                     &                     \\
F-test              &    5531.466         &      85.460         &                     &                     &                     \\
log(likelihood)     &     401.638         &     621.943         &                     &                     &                     \\
\hline\hline
\multicolumn{6}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{6}{l}{\footnotesize \sym{*} $$p<0.10$$, \sym{**} $$p<0.05$$, \sym{***} $$p<0.01$$}\\
\end{tabular}}
\end{sidewaystable}

\end{document}


If you have a look at the pdf, you will notice that:

1) The numbers, indicating the columns, are attached to the double line above. I tried to use \\ or \vspace after \hline\hline to obtain more space. However, it happens that more space is created below the numbers, not above. How can I get ride of this?

2) I would like to have more space between the coulmns. In Excel, I am used to add an extra column with a very small lenght. How can I do the same in latex?

Thanks, Dario

I would like to suggest that you make the following changes:

• To get better-spaced horizontal lines, don't use \hline and \cline. Instead, use the line-drawing macros of the booktabs package (which you've already loaded): \toprule, \midrule, \bottomrule, \cmidrule, and \addlinespace.

• To increase the amount of intercolumn whitespace, increase the value of the length parameter \tabcolsep. Its default value is 6pt; in the code below, I use 9pt. Feel free to set this parameter to suit your needs.

• Since you're loading the siunitx package, you might as well use its S column type for the five data columns.

\documentclass{article}
% I've reduced the preamble to the bare minimum needed to get the code to compile
\usepackage[labelfont=bf,skip=0.333\baselineskip]{caption}
\usepackage[utf8]{inputenc}
\usepackage{booktabs, siunitx}
\usepackage[textheight=27cm, textwidth=15cm]{geometry}
\sisetup{group-separator={},
table-format=-1.3,
input-symbols={()},
table-space-text-post=***}
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}
\pagenumbering{gobble}

\begin{document}

\begin{table}[htbp] % no need to use a 'sidewaystable' here, right?
\setlength{\tabcolsep}{9pt} % default: 6pt
\normalsize
\centering
\caption{Baseline model \label{table3}}

\begin{tabular}{@{} l *{5}{S} @{}}
\toprule
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)}\\
\midrule
lwlnyw    &  .984\sym{***}&  .674\sym{***}&   &  .519\sym{***} &  .957\sym{***}\\
& (.007)        & (.043)        &   & (.128)         & (.013)  \\
pc        & -.029\sym{**} & -.045\sym{***}& -.033\sym{***}& -.103\sym{***} & -.107\sym{***}\\
& (.015)  &  (.013)  &  (.013)  &  (.039)  &  (.036)  \\
pc2       &  .003\sym{**} & .004\sym{***}& .003\sym{***}& .010\sym{***}& .011\sym{***}\\
& (.001)        & (.001)       & (.001)       & (.004)          &  (.003)  \\
lnsnda2  \\
\\
\midrule
Observations        &  {681}   &  {681}  &  {681}  &  {553}  &  {681}  \\
N.\ of Obs.         &          &  {119}  &  {119}  &  {119}  &  {119}  \\
Overall $R^2$       &          &  .988   \\
$R^2$               &  .989    &  .723   \\
F-test              & {5531.5} &  {85.5} \\
Log-likelihood      &  {401.6} & {621.9} \\
\bottomrule
\addlinespace % a bit of (vertical) whitespace
\multicolumn{6}{@{}l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{6}{@{}l}{\footnotesize $\sym{*}\ p<0.10$; $\sym{**}\ p<0.05$; $\sym{***}\ p<0.01$}\\
\end{tabular}
\end{table}

\end{document}

• Thanks a lot for your suggestions. Much better than what I did. Only one small thing. The numbers after the second \midrule (Observations and so on...) are not really aligned to the other. How can i get this? Thanks again Apr 25 '17 at 16:32
• @Dario - The issue, really, is that the numbers below the second \midrule represent completely different categories: numbers of observations: postive integers; R^2: a number between 0 and 1; F-stat: a positive real number; and log-likelihood: any real number. While it is certainly possible, in principle, to align them on their (explicit or implicit) decimal markers, I'd say it's actually a very poor idea (typographically speaking) to do so, as it would create the impression that their types share something in common.
– Mico
Apr 25 '17 at 16:46
• @Dario - A second issue created by aligning all numbers in data columns 1 and 2 on their respective decimal markers would be that the columns would have to be made a lot wider. E.g., the largest number in data column 1 is 5531.5, while the smallest is -0.029**. Incidentally, if you really, really believe that the numbers in the final two rows ought to be aligned with respect to each other, I suggest you replace {401.6} with {\phantom{0}401.6}, and that you replace {85.5} with {\phantom{0}85.5}.
– Mico
Apr 25 '17 at 16:51