[Tex/LaTex] minipage horizontal alignment

horizontal alignmentminipagetables

I'm using minipage to put two tables next to each other, and instead it is putting them in vertically. It seems like this is usually caused by having blank lines between the minipages, but that isn't the case here. What can I do to rectify this?

\documentclass{article}
\usepackage{fullpage}
\begin{document}    
\begin{table}[htbp]\centering
\begin{minipage}[c]{\textwidth}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{phone T-tests}
\begin{tabular}{l*{1}{c}}
\hline\hline
                    &\multicolumn{1}{c}{Altruism\&Image}\\
\hline
pledge              &       10.00         \\
                &     (16.12)         \\
[1em]
pledge\_zeros        &       8.020         \\
                    &     (4.311)         \\
[1em]
pledge\_binary       &      0.0924\sym{**} \\
                    &    (0.0326)         \\
\hline
Observations        &         710         \\
\hline\hline
\multicolumn{2}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{2}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \                        (p<0.001\)}\\
\end{tabular}
\end{minipage}
\begin{minipage}[c]{\textwidth}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{phone T-tests}
\begin{tabular}{l*{1}{c}}
\hline\hline
                    &\multicolumn{1}{c}{Alruism\&Pressure}\\
\hline
pledge              &      -3.091         \\
                    &     (15.40)         \\
[1em]
pledge\_zeros        &       0.781         \\
                    &     (4.831)         \\
[1em]
pledge\_binary       &      0.0243         \\
                    &    (0.0350)         \\
\hline
Observations        &         680         \\
\hline\hline
\multicolumn{2}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{2}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \    (p<0.001\)}\\

\end{tabular}
\end{minipage}
\end{table}
\end{document}

Best Answer

You have \textwidth wide minipages; however, in cases like these, it's better to use threeparttable, so the caption will be properly centered over the table.

\documentclass{article}
\usepackage{fullpage}
\usepackage{threeparttable}
\begin{document}    
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{minipage}{.45\textwidth}
\begin{threeparttable}
\caption{phone T-tests}
\begin{tabular}{l*{1}{c}}
\hline\hline
                    &\multicolumn{1}{c}{Altruism\&Image}\\
\hline
pledge              &       10.00         \\
                &     (16.12)         \\
[1em]
pledge\_zeros        &       8.020         \\
                    &     (4.311)         \\
[1em]
pledge\_binary       &      0.0924\sym{**} \\
                    &    (0.0326)         \\
\hline
Observations        &         710         \\
\hline\hline
\multicolumn{2}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{2}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \                        \(p<0.001\)}\\
\end{tabular}
\end{threeparttable}
\end{minipage}\hfill
\begin{minipage}{.45\textwidth}
\begin{threeparttable}
\caption{phone T-tests}
\begin{tabular}{l*{1}{c}}
\hline\hline
                    &\multicolumn{1}{c}{Alruism\&Pressure}\\
\hline
pledge              &      -3.091         \\
                    &     (15.40)         \\
[1em]
pledge\_zeros        &       0.781         \\
                    &     (4.831)         \\
[1em]
pledge\_binary       &      0.0243         \\
                    &    (0.0350)         \\
\hline
Observations        &         680         \\
\hline\hline
\multicolumn{2}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{2}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \    \(p<0.001\)}\\

\end{tabular}
\end{threeparttable}
\end{minipage}
\end{table}
\end{document}

Notice also \begin{minipage}[t], so the vertical alignment will be with respect to the captions.

enter image description here

Related Question