我有以下代码,它应该生成 2 个并排的表格。但是,左侧表格太靠左,以至于其后半部分在那里,右侧表格也在其后。我该如何正确定位它们?
\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}
如果有人能帮忙,那就太好了。
答案1
看起来您很乐意让表格紧贴在边距中。但是您遇到了几个问题:左侧表格的标题比表格宽,而右侧表格比左侧表格宽。
因此,首先我会稍微放大左边的表格(带有\addtolength{\tabcolsep}{2pt}
),并测量这两个表格,以便构建具有所需精确宽度的小页面。
\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}
如果您想要减小尺寸,可以使用以下方法caption
:
\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}
答案2
为什么要有\makebox
?删除它并改变minipage
宽度,我们得到:
\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}