0

I'm trying to place two tables created by R package stargazer side by side. Been searching a lot for a solution to this, and here below is a code I ran but doesn't get the result I wanted. I expect to have my tables resized in a way that they would fit one next the other. Using a solution I found with minipage I get full sized tables, one under the other, even though I set {.5\textwidth}. My minimized example is the following:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}    
\usepackage[hidelinks]{hyperref}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage[font=footnotesize]{subcaption}
\usepackage[labelfont=bf]{caption}
\usepackage{float}
\usepackage{comment}
\usepackage{geometry}
\usepackage{wrapfig}
\usepackage{booktabs} 
\usepackage{tabulary}
\usepackage{pdflscape}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{placeins}
\usepackage{setspace}
\usepackage{dcolumn}
\usepackage{adjustbox}

\geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in}
\begin{document}

\begin{table}[!htb]
\begin{minipage}[t]{.5\textwidth}
\centering
    \caption{Table 1}
\begin{tabular}{@{\extracolsep{5pt}}lccccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{5}{c}{\textit{Dependent variable:}} \\ 
\cline{2-6} 
\\[-1.8ex] & \multicolumn{5}{c}{} \\ 
 & \multicolumn{2}{c}{} & \multicolumn{3}{c}{} \\ 
\\[-1.8ex] & (1) & (2) & (3) & (4) & (5)\\ 
\hline \\[-1.8ex] 
 Coefs & $-$0.096 &  & $-$0.047 &  &  \\ 
  & (0.065) &  & (0.091) &  &  \\ 
  & & & & & \\ 
 Coefs &  & $-$0.038 &  & $-$0.017 &  \\ 
  &  & (0.026) &  & (0.040) &  \\ 
  & & & & & \\ 
 Coefs &  &  &  &  & $-$0.095$^{***}$ \\ 
  &  &  &  &  & (0.028) \\ 
  & & & & & \\ 
 Coefs &  &  & 0.130 & 0.131 &  \\ 
  &  &  & (0.171) & (0.188) &  \\ 
  & & & & & \\ 
\hline \\[-1.8ex] 
Observations & 228 & 228 & 228 & 228 & 228 \\ 
R$^{2}$ & 0.009 & 0.010 & 0.012 & 0.012 & 0.049 \\ 
\hline 
\hline \\[-1.8ex] 
\multicolumn{6}{l}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\centering
\caption{Table 2}
\begin{tabular}{@{\extracolsep{5pt}}lccccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{5}{c}{\textit{Dependent variable:}} \\ 
\cline{2-6} 
\\[-1.8ex] & \multicolumn{5}{c}{} \\ 
 & \multicolumn{2}{c}{} & \multicolumn{3}{c}{} \\ 
\\[-1.8ex] & (1) & (2) & (3) & (4) & (5)\\ 
\hline \\[-1.8ex] 
 Coefs & $-$0.033$^{*}$ &  & $-$0.025 &  &  \\ 
  & (0.017) &  & (0.024) &  &  \\ 
  & & & & & \\ 
 Coefs &  & $-$0.012$^{*}$ &  & $-$0.008 &  \\ 
  &  & (0.007) &  & (0.010) &  \\ 
  & & & & & \\ 
 Coefs &  &  &  &  & $-$0.029$^{***}$ \\ 
  &  &  &  &  & (0.007) \\ 
  & & & & & \\ 
 Coefs &  &  & 0.022 & 0.027 &  \\ 
  &  &  & (0.045) & (0.050) &  \\ 
  & & & & & \\ 
\hline \\[-1.8ex] 
Observations & 228 & 228 & 228 & 228 & 228 \\ 
R$^{2}$ & 0.016 & 0.014 & 0.017 & 0.015 & 0.067 \\ 
\hline 
\hline \\[-1.8ex] 
\multicolumn{6}{l}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{minipage}
\end{table}
\end{document}

This is the result I get:

This is the result I get:

Update: I actually tried every solution suggested in that "duplicated" post. None of them succeeds in resizing and fitting the tables one next to the other. When eliminating the paragraph break, I get one table on top of the other, like the following:

enter image description here

MNW (basically the same, without paragraph break):

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}    
\usepackage[hidelinks]{hyperref}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage[font=footnotesize]{subcaption}
\usepackage[labelfont=bf]{caption}
\usepackage{float}
\usepackage{comment}
\usepackage{geometry}
\usepackage{wrapfig}
\usepackage{booktabs} 
\usepackage{tabulary}
\usepackage{pdflscape}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{placeins}
\usepackage{setspace}
\usepackage{dcolumn}
\usepackage{adjustbox}

\geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in}
\begin{document}

\begin{table}[!htb]
\begin{minipage}[t]{.5\textwidth}
\centering
    \caption{Table 1}
\begin{tabular}{@{\extracolsep{5pt}}lccccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{5}{c}{\textit{Dependent variable:}} \\ 
\cline{2-6} 
\\[-1.8ex] & \multicolumn{5}{c}{} \\ 
 & \multicolumn{2}{c}{} & \multicolumn{3}{c}{} \\ 
\\[-1.8ex] & (1) & (2) & (3) & (4) & (5)\\ 
\hline \\[-1.8ex] 
 Coefs & $-$0.096 &  & $-$0.047 &  &  \\ 
  & (0.065) &  & (0.091) &  &  \\ 
  & & & & & \\ 
 Coefs &  & $-$0.038 &  & $-$0.017 &  \\ 
  &  & (0.026) &  & (0.040) &  \\ 
  & & & & & \\ 
 Coefs &  &  &  &  & $-$0.095$^{***}$ \\ 
  &  &  &  &  & (0.028) \\ 
  & & & & & \\ 
 Coefs &  &  & 0.130 & 0.131 &  \\ 
  &  &  & (0.171) & (0.188) &  \\ 
  & & & & & \\ 
\hline \\[-1.8ex] 
Observations & 228 & 228 & 228 & 228 & 228 \\ 
R$^{2}$ & 0.009 & 0.010 & 0.012 & 0.012 & 0.049 \\ 
\hline 
\hline \\[-1.8ex] 
\multicolumn{6}{l}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\centering
\caption{Table 2}
\begin{tabular}{@{\extracolsep{5pt}}lccccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{5}{c}{\textit{Dependent variable:}} \\ 
\cline{2-6} 
\\[-1.8ex] & \multicolumn{5}{c}{} \\ 
 & \multicolumn{2}{c}{} & \multicolumn{3}{c}{} \\ 
\\[-1.8ex] & (1) & (2) & (3) & (4) & (5)\\ 
\hline \\[-1.8ex] 
 Coefs & $-$0.033$^{*}$ &  & $-$0.025 &  &  \\ 
  & (0.017) &  & (0.024) &  &  \\ 
  & & & & & \\ 
 Coefs &  & $-$0.012$^{*}$ &  & $-$0.008 &  \\ 
  &  & (0.007) &  & (0.010) &  \\ 
  & & & & & \\ 
 Coefs &  &  &  &  & $-$0.029$^{***}$ \\ 
  &  &  &  &  & (0.007) \\ 
  & & & & & \\ 
 Coefs &  &  & 0.022 & 0.027 &  \\ 
  &  &  & (0.045) & (0.050) &  \\ 
  & & & & & \\ 
\hline \\[-1.8ex] 
Observations & 228 & 228 & 228 & 228 & 228 \\ 
R$^{2}$ & 0.016 & 0.014 & 0.017 & 0.015 & 0.067 \\ 
\hline 
\hline \\[-1.8ex] 
\multicolumn{6}{l}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{minipage}
\end{table}
\end{document}
7
  • 1
    you have a paragraph break (blank line) between the minipages so they come one above the other, Commented Nov 6, 2017 at 23:34
  • @DavidCarlisle, see my update.
    – nadavb
    Commented Nov 7, 2017 at 7:58
  • 1
    Please show a MWE for the new image. Without the question is either still a duplicate or unclear and there is no reason for reopening it. Commented Nov 7, 2017 at 9:02
  • Added. It is basically the same, just removed the paragraph break like @DavidCarlisle mentioned.
    – nadavb
    Commented Nov 7, 2017 at 9:26
  • Your question asked about how to make the tables go side by side and that is a duplicate. The new question asks about how to change the width of the table and that is a different issue but a duplicate of any one of a thousand questions on this site, you are using cccccc so natural width and \normalsize so it's too big, use \small` or \tiny or whatever you need or use fixed width columns such as p{1cm} just search for table and width on this site. Commented Nov 7, 2017 at 9:31

0

Browse other questions tagged .