多个桌子放在一个矩形内

多个桌子放在一个矩形内

我正在尝试报告与 State 完全相同的回归表。我使用tabular代码生成了 3 个不同的表格,如下所示。

\begin{table}[h]
\begin{tabular}{l|lrrr}
Source   &  & SS         & df  & MS         \\ \hline
Model    &  & .00570871  & 1   & .00570871  \\
Residual &  & 863.13874  & 892 & .967644327 \\ \hline
Total    &  & 863.144449 & 893 & .966567132
\end{tabular}
\quad
\begin{tabular}{llr}
Number of obs       & = & 894     \\
F(1, 892)           & = & 0.01    \\
Prob \textgreater F & = & 0.9388  \\
R-squared           & = & 0.0000  \\
Adj R-squared       & = & -0.0011 \\
Root MSE            & = & .98369 
\end{tabular}

\begin{tabular}{llrrrrrr} \hline
mathsc6 &  & Coef.     & Std. Err. & t     & P\textgreater|t| &        \multicolumn{2}{r}{{[}95\% Conf. Interval{]}} \\ \hline
treated &  & -.0050743 & .066064   & -0.08 & 0.939            &  -.1347333              & .1245847             \\
\_cons  &  & .0196085  & .0487597  & 0.40  & .0688            &  -.0760885              & .1153055        \\ \hline    
\end{tabular}
\end{table}

有没有办法将整个桌子放在一个矩形中,就像照片中那样?

在此处输入图片描述

所谓“适合”,是指将第三个表格加宽至整个文本宽度。前两个表格加起来应与文本宽度(即第三个表格)一样大。此外,第一个表格的高度应与第二个表格的高度相同。

先感谢您 :)

答案1

像这样?此解决方案tabular在上部使用两个顶部对齐的环境,然后tabular*在下部使用全宽环境。

在此处输入图片描述

\documentclass{article}

%% Set up typographic structs:
\newcommand\T{\rule{0pt}{2.6ex}}       % "top" strut
\newcommand\B{\rule[-1.3ex]{0pt}{0pt}} % "bottom" strut
\newcommand{\TB}{\T\B} % top&bottom struts

\begin{document}

\begin{table}
\ttfamily
\begin{tabular}[t]{@{}r|rrr@{}}
Source\B   & SS         & df  & MS         \\ \hline
Model\T    & .00570871  & 1   & .00570871  \\
Residual\B & 863.13874  & 892 & .967644327 \\ \hline
Total\T    & 863.144449 & 893 & .966567132
\end{tabular}%
\hspace*{\fill}
\begin{tabular}[t]{@{}llr@{}}
Number of obs       & = & 894     \\
F(1, 892)           & = & 0.01    \\
Prob \textgreater\ F& = & 0.9388  \\
R-squared           & = & 0.0000  \\
Adj R-squared       & = & -0.0011 \\
Root MSE            & = & .98369 
\end{tabular}

\bigskip
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{7}{r}} 
\hline
mathsc6\TB &  Coef. & Std.\ Err. & t~ & P\textgreater|t| 
    & \multicolumn{2}{c@{}}{[95\% Conf.\ Interval]} \\ 
\hline
treated\T & -.0050743 & .066064 & -0.08 & 0.939 & -.1347333 & .1245847  \\
\_cons\B  & .0196085  & .0487597 & 0.40 & .0688 & -.0760885 & .1153055  \\ 
\hline    
\end{tabular*}
\end{table}
\end{document}

答案2

以下示例使用

  • tabular用于放置内部桌子的外部
  • siunitx用于对齐和打印数字列的包,
  • 用普通字体代替打字机原版字体,
  • 尝试检测并设置数学公式或变量(不完整)。

示例文件(输入的表格数据来自 Mico 的回答):

\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{center}% or environment "table"
  \begin{tabular}{@{}lr@{}}
    \begin{tabular}[t]{
      l
      S[table-format=3.8]
      S[table-format=3]
      S[table-format=1.9]
    }
      \toprule
      Source   & {SS}       & {df} & {MS}       \\
      \midrule
      Model    & .00570871  & 1    & .00570871  \\
      Residual & 863.13874  & 892  & .967644327 \\
      Total    & 863.144449 & 893  & .966567132 \\
      \bottomrule
    \end{tabular}
    &
    \begin{tabular}[t]{l@{ = }S[table-format=3.5]}% The minus in "-0.0011" is covered by 3 from 3.5
      \toprule
      Number of obs       & 894     \\
      F(1, 892)           & 0.01    \\
      Prob \textgreater\ F& 0.9388  \\
      R-squared           & 0.0000  \\
      Adj R-squared       & -0.0011 \\
      Root MSE            & .98369  \\
    \bottomrule
    \end{tabular}%
    \tabularnewline
    \addlinespace[2ex]
    \multicolumn{2}{@{}c@{}}{%
      \begin{tabular}{
        l
        S[table-format=-1.7]
        S[table-format=1.7]
        S[table-format=-1.2]
        S[table-format=1.4]
        S[table-format=-1.7]
        S[table-format=-1.7]
      }
        \toprule
        mathsc6 &  {Coef.} & {Std.\@ Err.} & {$t$} & {$P>|t|$}
        & \multicolumn{2}{c}{[\SI{95}{\percent} Conf.\@ Interval]} \\
        \midrule
        treated & -.0050743 & .066064 & -0.08 & 0.939 & -.1347333 & .1245847  \\
        \_cons  & .0196085  & .0487597 & 0.40 & .0688 & -.0760885 & .1153055  \\
        \bottomrule
      \end{tabular}%
    }
  \end{tabular}
\end{center}
\end{document}

结果

相关内容