5

I have the following code, it should generate 2 side-by-side tables. However, the left table is too left that its last half is there, and the right table thereafter. How can I position them properly?

\begin{table}[tbh!]
\makebox[0pt][c]{\parbox{1.2\textwidth}{%
\begin{minipage}[b]{0.6\linewidth} % A minipage that covers half the page 
\centering
\caption{obs=1000, Coverage Probability}
\begin{tabular}{lcccc}
\toprule
Estimators & G=3 & G=10 & G=30\\ 
\midrule
2SLS & 0.849 & 0.850 & 0.850\\ 
GMM & 0.850 & 0.849 & 0.851\\ 
EL & 0.848 & 0.850 & 0.851\\ 
EL biascorr & 0.848 & 0.850 & 0.851\\ 
\bottomrule
\end{tabular}
\end{minipage}%
 \begin{minipage}[b]{0.4\linewidth}\centering
\caption{obs=1000, Test Statistic}
\begin{tabular}{lcccc}
\toprule
Number of acceptances & G=3 & G=10 & G=30\\ 
\midrule
Overidentification&&&\\
restrictions test & 893 & 831 & 720\\
Wald Test & 893 & 831 & 723\\ 
LM test & 893 & 831 & 718\\ 
\bottomrule
\end{tabular}
\end{minipage}%
}}
\end{table}

If someone can help, it will be great.

David Carlisle
  • 757,742

2 Answers2

4

It seems that you're happy to make the table stick in the margin. But you have several problems: the caption for the table on the left is wider than the table, and the table on the right is wider than the left one.

So first of all I'd enlarge a bit the left table (with \addtolength{\tabcolsep}{2pt}) and measure the two tables, so as to build minipages of the exact required width.

\documentclass{article}
\usepackage{booktabs,lipsum,calc}

\newsavebox{\leftbox}
\newsavebox{\rightbox}

\begin{document}
\lipsum[2]

\begin{table}[tbh!]

\begin{lrbox}{\leftbox}
\addtolength{\tabcolsep}{2pt}%
\begin{tabular}{lccc}
\toprule
Estimators & G=3 & G=10 & G=30\\ 
\midrule
2SLS & 0.849 & 0.850 & 0.850\\ 
GMM & 0.850 & 0.849 & 0.851\\ 
EL & 0.848 & 0.850 & 0.851\\ 
EL biascorr & 0.848 & 0.850 & 0.851\\ 
\bottomrule
\end{tabular}
\end{lrbox}

\begin{lrbox}{\rightbox}
\begin{tabular}{lccc}
\toprule
Number of acceptances & G=3 & G=10 & G=30\\ 
\midrule
Overidentification&&&\\
restrictions test & 893 & 831 & 720\\
Wald Test & 893 & 831 & 723\\ 
LM test & 893 & 831 & 718\\ 
\bottomrule
\end{tabular}
\end{lrbox}

\centering
\makebox[0pt]{%
\begin{minipage}[b]{\wd\leftbox} % A minipage that covers half the page 
\centering
\caption{obs=1000, Coverage Probability}
\usebox{\leftbox}
\end{minipage}\quad
\begin{minipage}[b]{\wd\rightbox}
\centering
\caption{obs=1000, Test Statistic}
\usebox{\rightbox}
\end{minipage}%
}
\end{table}
\end{document}

enter image description here

If you want to reduce the size, here's how you can do it with the caption package:

\documentclass{article}
\usepackage{booktabs,lipsum,calc}
\usepackage{caption}

\newsavebox{\leftbox}
\newsavebox{\rightbox}

\begin{document}
\lipsum[2]

\begin{table}[tbh!]
\footnotesize\captionsetup{font=footnotesize,aboveskip=2pt}
\begin{lrbox}{\leftbox}
\addtolength{\tabcolsep}{1pt}%
\begin{tabular}{lccc}
\toprule
Estimators & G=3 & G=10 & G=30\\ 
\midrule
2SLS & 0.849 & 0.850 & 0.850\\ 
GMM & 0.850 & 0.849 & 0.851\\ 
EL & 0.848 & 0.850 & 0.851\\ 
EL biascorr & 0.848 & 0.850 & 0.851\\ 
\bottomrule
\end{tabular}
\end{lrbox}

\begin{lrbox}{\rightbox}
\begin{tabular}{lccc}
\toprule
Number of acceptances & G=3 & G=10 & G=30\\ 
\midrule
Overidentification&&&\\
restrictions test & 893 & 831 & 720\\
Wald Test & 893 & 831 & 723\\ 
LM test & 893 & 831 & 718\\ 
\bottomrule
\end{tabular}
\end{lrbox}

\centering
\makebox[0pt]{%
\begin{minipage}[b]{\wd\leftbox} % A minipage that covers half the page 
\centering
\caption{obs=1000, Coverage Probability}
\usebox{\leftbox}
\end{minipage}\quad
\begin{minipage}[b]{\wd\rightbox}
\centering
\caption{obs=1000, Test Statistic}
\usebox{\rightbox}
\end{minipage}%
}
\end{table}
\end{document}

enter image description here

David Carlisle
  • 757,742
egreg
  • 1,121,712
2

Why to have \makebox? Removing it and changing the minipage widths, we get:

\documentclass{article}
\usepackage{booktabs}
\usepackage[margin=1in]{geometry}
\begin{document}

\begin{table}[tbh!]
%\makebox[0pt][c]{\parbox{1.2\textwidth}{%
\begin{minipage}[b]{0.5\linewidth} % A minipage that covers half the page
\centering
\caption{obs=1000, Coverage Probability}
\begin{tabular}{lcccc}
\toprule
Estimators & G=3 & G=10 & G=30\\
\midrule
2SLS & 0.849 & 0.850 & 0.850\\
GMM & 0.850 & 0.849 & 0.851\\
EL & 0.848 & 0.850 & 0.851\\
EL biascorr & 0.848 & 0.850 & 0.851\\
\bottomrule
\end{tabular}
\end{minipage}%
 \begin{minipage}[b]{0.5\linewidth}
 \centering
\caption{obs=1000, Test Statistic}
\begin{tabular}{lcccc}
\toprule
Number of acceptances & G=3 & G=10 & G=30\\
\midrule
Overidentification&&&\\
restrictions test & 893 & 831 & 720\\
Wald Test & 893 & 831 & 723\\
LM test & 893 & 831 & 718\\
\bottomrule
\end{tabular}
\end{minipage}%
%}%}
\end{table}
\end{document}

enter image description here

Moriambar
  • 11,466
  • Well, maybe the OP is not allowed to change the page setup. – egreg Dec 03 '12 at 00:21
  • @egreg: It is a possibility. But then the option is to reduce the font size, or encroach the table into the margin. Both may not be permitted too. :-) –  Dec 03 '12 at 00:31