创建两个堆叠的表格和一个右侧的表格的图形

创建两个堆叠的表格和一个右侧的表格的图形

我想创建一个这样的图形,其中“空间面板数据模型”表位于另外两个堆叠表的右侧(而不是左侧):

在此处输入图片描述

我编写了以下代码,其产生的结果如下:

\begin{center}
\begin{tabular}{c@{\quad}c@{\quad}c}
    Cross-Sectional Data   &   Time Series Data   &   Panel Data   \\
\begin{tabular}[t]{|c|c|c|c|}
    \hline
            $\bm{i}$ & $\bm{t}$ & $\bm{y}$ & $\bm{x}$\\  \hline
               $1$ & $1$ & $y_{1,1}$ & $x_{1,1}$ \\ 
            $1$  & $2$ & $y_{2,1}$ & $x_{2,1}$ \\ 
            $1$ & $3$ & $y_{3,1}$ & $x_{3,1}$ \\ \hline
\end{tabular}
    &   \begin{tabular}[t]{|c|c|c|c|}
        \hline
                $\bm{i}$ & $\bm{t}$ & $\bm{y}$ & $\bm{x}$\\  \hline
               $1$ & $1$ & $y_{1,1}$ & $x_{1,1}$ \\ 
            $1$  & $2$ & $y_{1,2}$ & $x_{1,2}$ \\ 
            $1$ & $3$ & $y_{1,3}$ & $x_{1,3}$ \\ \hline
    \end{tabular}
        &   \begin{tabular}[t]{|c|c|c|c|}
            \hline
            $\bm{i}$ & $\bm{t}$ & $\bm{y}$ & $\bm{x}$\\  \hline
               $1$ & $1$ & $y_{1,1}$ & $x_{1,1}$ \\ 
            $1$  & $2$ & $y_{1,2}$ & $x_{1,2}$ \\ 
            $1$ & $3$ & $y_{1,3}$ & $x_{1,3}$ \\ 
            $2$ & $1$ & $y_{2,1}$ & $x_{2,1}$ \\ 
            $2$ & $2$ & $y_{2,2}$ & $x_{2,2}$ \\ 
            $2$ & $3$ & $y_{2,3}$ & $x_{2,3}$ \\ 
            $3$ & $1$ & $y_{3,1}$ & $x_{3,1}$ \\ 
            $3$ & $2$ & $y_{3,2}$ & $x_{3,2}$ \\ 
            $3$ & $3$ & $y_{3,3}$ & $x_{3,3}$ \\ \hline
            \end{tabular}
\end{tabular}
\end{center}

在此处输入图片描述

是否有可能左边两个表,上面是“横截面”表,下面是“时间序列”表?那么“面板数据”仍然在右边吗?

答案1

array使用和subtable来自包的两种替代方案subcaption

在此处输入图片描述

\documentclass{article}
\usepackage{subcaption}
\usepackage{bm}

\usepackage{booktabs} % only used in second example

\begin{document}
\captionsetup[subtable]{position=above}

\begin{table}
  \centering
  \caption{shared caption for all three subtables}
  \begin{subtable}[t]{0.45\linewidth}
    \centering
    \caption{Cross-Sectional Data}
    \(\begin{array}{|c|c|c|c|}
      \hline
      \bm{i} & \bm{t} & \bm{y}  & \bm{x}  \\  
      \hline
      1      & 1      & y_{1,1} & x_{1,1} \\ 
      1      & 2      & y_{2,1} & x_{2,1} \\ 
      1      & 3      & y_{3,1} & x_{3,1} \\ 
      \hline
    \end{array}\)
    \medskip

    \caption{Time Series Data}
    \(\begin{array}{|c|c|c|c|}
        \hline
         \bm{i} & \bm{t} & \bm{y}  & \bm{x}  \\  
         \hline
         1      & 1      & y_{1,1} & x_{1,1} \\ 
         1      & 2      & y_{1,2} & x_{1,2} \\ 
         1      & 3      & y_{1,3} & x_{1,3} \\ 
         \hline
    \end{array}\)
  \end{subtable}
  \begin{subtable}[t]{0.45\linewidth}
    \centering
    \caption{Panel Data}
    \(\begin{array}{|c|c|c|c|}
      \hline
      \bm{i} & \bm{t} & \bm{y}  & \bm{x}  \\  
      \hline
      1      & 1      & y_{1,1} & x_{1,1} \\ 
      1      & 2      & y_{1,2} & x_{1,2} \\ 
      1      & 3      & y_{1,3} & x_{1,3} \\ 
      2      & 1      & y_{2,1} & x_{2,1} \\ 
      2      & 2      & y_{2,2} & x_{2,2} \\ 
      2      & 3      & y_{2,3} & x_{2,3} \\ 
      3      & 1      & y_{3,1} & x_{3,1} \\ 
      3      & 2      & y_{3,2} & x_{3,2} \\ 
      3      & 3      & y_{3,3} & x_{3,3} \\ 
      \hline
    \end{array}\)
  \end{subtable}
\end{table}


\begin{table}
  \centering
  \caption{shared caption for all three subtables}
  \begin{subtable}[t]{0.45\linewidth}
    \centering
    \caption{Cross-Sectional Data}
    
    \(\begin{array}{cccc}
      \toprule
      \bm{i} & \bm{t} & \bm{y}  & \bm{x}  \\  
      \midrule
      1      & 1      & y_{1,1} & x_{1,1} \\ 
      1      & 2      & y_{2,1} & x_{2,1} \\ 
      1      & 3      & y_{3,1} & x_{3,1} \\ 
      \bottomrule
    \end{array}\)
    \medskip

    \caption{Time Series Data}
    
    \(\begin{array}{cccc}
      \toprule
      \bm{i} & \bm{t} & \bm{y}  & \bm{x}  \\  
      \midrule
      1      & 1      & y_{1,1} & x_{1,1} \\ 
      1      & 2      & y_{1,2} & x_{1,2} \\ 
      1      & 3      & y_{1,3} & x_{1,3} \\ 
      \bottomrule
    \end{array}\)
  \end{subtable}
  \begin{subtable}[t]{0.45\linewidth}
    \centering
    \caption{Panel Data}
    \(\begin{array}{cccc}
      \toprule
      \bm{i} & \bm{t} & \bm{y}  & \bm{x}  \\  
      \midrule
      1      & 1      & y_{1,1} & x_{1,1} \\ 
      1      & 2      & y_{1,2} & x_{1,2} \\ 
      1      & 3      & y_{1,3} & x_{1,3} \\
      \addlinespace 
      2      & 1      & y_{2,1} & x_{2,1} \\ 
      2      & 2      & y_{2,2} & x_{2,2} \\ 
      2      & 3      & y_{2,3} & x_{2,3} \\
      \addlinespace
      3      & 1      & y_{3,1} & x_{3,1} \\ 
      3      & 2      & y_{3,2} & x_{3,2} \\ 
      3      & 3      & y_{3,3} & x_{3,3} \\ 
      \bottomrule
    \end{array}\)
  \end{subtable}
\end{table}

\end{document}

答案2

像这样?

\documentclass{article}
\usepackage{caption, subcaption}
\usepackage{ragged2e} 
\usepackage{bm}
\begin{document}

\begin{table}
\captionsetup{font=bf, position=above, justification=RaggedRight}
\hfill\begin{minipage}[t]{0.3\linewidth}
\centering
\subcaptionbox{Cross-sectional data models}{\begin{tabular}{|c|c|c|c|}
    \hline
            $\bm{i}$ & $\bm{t}$ & $\bm{y}$ & $\bm{x}$\\ \hline
               $1$ & $1$ & $y_{1,1}$ & $x_{1,1}$ \\
            $1$ & $2$ & $y_{2,1}$ & $x_{2,1}$ \\
            $1$ & $3$ & $y_{3,1}$ & $x_{3,1}$ \\ \hline
\end{tabular}}\bigskip

  \subcaptionbox{Time series data models}{\begin{tabular}{|c|c|c|c|}
        \hline
                $\bm{i}$ & $\bm{t}$ & $\bm{y}$ & $\bm{x}$\\ \hline
               $1$ & $1$ & $y_{1,1}$ & $x_{1,1}$ \\
            $1$ & $2$ & $y_{1,2}$ & $x_{1,2}$ \\
            $1$ & $3$ & $y_{1,3}$ & $x_{1,3}$ \\ \hline
    \end{tabular}}
\end{minipage}
\qquad
\begin{minipage}[t]{0.3\linewidth}
\centering
\subcaptionbox{Spatial panel data models}{\begin{tabular}{|c|c|c|c|}
            \hline
            $\bm{i}$ & $\bm{t}$ & $\bm{y}$ & $\bm{x}$\\ \hline
               $1$ & $1$ & $y_{1,1}$ & $x_{1,1}$ \\
            $1$ & $2$ & $y_{1,2}$ & $x_{1,2}$ \\
            $1$ & $3$ & $y_{1,3}$ & $x_{1,3}$ \\
            $2$ & $1$ & $y_{2,1}$ & $x_{2,1}$ \\
            $2$ & $2$ & $y_{2,2}$ & $x_{2,2}$ \\
            $2$ & $3$ & $y_{2,3}$ & $x_{2,3}$ \\
            $3$ & $1$ & $y_{3,1}$ & $x_{3,1}$ \\
            $3$ & $2$ & $y_{3,2}$ & $x_{3,2}$ \\
            $3$ & $3$ & $y_{3,3}$ & $x_{3,3}$ \\ \hline
            \end{tabular}}
\end{minipage}
\hfill\mbox{}
\end{table}

\end{document} 

在此处输入图片描述

相关内容