使用 tabularx 制作横跨多页的面板表格

使用 tabularx 制作横跨多页的面板表格

我使用 tabularx 创建了一个 4 面板表格。但是,表格和表格注释使这个表格非常大,因此我想对其进行景观设计,并将表格横跨两页。但是,我的景观设计实验失败了,如果能得到任何帮助,我将不胜感激。

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}% To set line spacing commands like \doublespacing
\usepackage{graphicx} %helps include \includegraphics
\usepackage{tikz} % To draw tikz pictures
\usepackage{pdflscape}
\usepackage{array}
\usepackage{tabularx} % To create panelled tables
\usepackage{booktabs}
\doublespacing

\begin{document}
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{landscape}

    \begin{table}[htbp]\renewcommand{\arraystretch}{1.3} 
        \caption{Table Caption Here}
        \label{panel_table}
        \centering
        \resizebox{0.8\textwidth}{!}{%
            \begin{tabularx}{\linewidth}{l*{4}{Y}}
                \toprule 
                \multicolumn{5}{c}{\textbf{Panel A}}\\
                \multicolumn{5}{c}{\textit{Dep. Var: } Some Dep Variable Here} \\\midrule

                &\multicolumn{2}{c}{Approach One} & \multicolumn{2}{c}{Approach Two} \\ 
                \cmidrule(lr){2-3}
                \cmidrule(lr){4-5} 

                &  \multicolumn{2}{c}{Citation for One}    &  \multicolumn{2}{c}{Citation for Two}\\ 
                & (1) & (2) & (3) & (4) \\ \midrule 
                Ind Variable &  1.1111*** & 1.1111**   & 1.1111**  & 1.1111**  \\
                &  (1.11111) & (1.11111)  & (1.11111) & (1.11111) \\  \midrule
                Observations & 5000 & 1,5000 & 1,5000 & 1,5000 \\ 
              \bottomrule   
            \end{tabularx}
        }
        \resizebox{0.8\textwidth}{!}{%
        \begin{tabularx}{\linewidth}{l*{4}{Y}}
            \toprule 
            \multicolumn{5}{c}{\textbf{Panel B}}\\
            \multicolumn{5}{c}{\textit{Dep. Var: } Some Dep Variable Here} \\\midrule

            &\multicolumn{2}{c}{Approach One} & \multicolumn{2}{c}{Approach Two} \\ 
            \cmidrule(lr){2-3}
            \cmidrule(lr){4-5} 

            &  \multicolumn{2}{c}{Citation for One}    &  \multicolumn{2}{c}{Citation for Two}\\ 
            & (1) & (2) & (3) & (4) \\ \midrule 
            Ind Variable &  1.1111*** & 1.1111**   & 1.1111**  & 1.1111**  \\
            &  (1.11111) & (1.11111)  & (1.11111) & (1.11111) \\  \midrule
            Observations & 5000 & 1,5000 & 1,5000 & 1,5000 \\ 
            \bottomrule 
        \end{tabularx}
    }

    \resizebox{0.8\textwidth}{!}{%
    \begin{tabularx}{\linewidth}{l*{4}{Y}}
        \toprule 

        \multicolumn{5}{c}{\textbf{Panel C}}\\
        \multicolumn{5}{c}{\textit{Dep. Var: } Some Dep Variable Here} \\\midrule

        &\multicolumn{2}{c}{Approach One} & \multicolumn{2}{c}{Approach Two} \\ 
        \cmidrule(lr){2-3}
        \cmidrule(lr){4-5} 

        &  \multicolumn{2}{c}{Citation for One}    &  \multicolumn{2}{c}{Citation for Two}\\ 
        & (1) & (2) & (3) & (4) \\ \midrule 
        Ind Variable &  1.1111*** & 1.1111**   & 1.1111**  & 1.1111**  \\
        &  (1.11111) & (1.11111)  & (1.11111) & (1.11111) \\  \midrule
        Observations & 5000 & 1,5000 & 1,5000 & 1,5000 \\ 
        \bottomrule 
    \end{tabularx}
}

        \resizebox{0.8\textwidth}{!}{%
            \begin{tabularx}{\linewidth}{l*{3}{Y}} \toprule
                \multicolumn{3}{c}{Panel D}\\
                Variables &\multicolumn{2}{c}{Another Dep Variable} \\ 
                & (1) & (2) \\\midrule
                genderquota & 1.1111*** & 1.1111**\\
                & (1.1111) & (1.1111) \\
                Constant & 1.1111*** & 1.1111**\\
                & (1.1111) & (1.1111)  \\\midrule
                Observations & 1,1212 & 1,123123 \\
                R-squared & 0.022 & 0.267 \\  
                 \bottomrule
                \multicolumn{3}{c}{ Standard errors in parentheses are clustered} \\
                \multicolumn{3}{c}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.1} \\
        \end{tabularx} } 
        \begin{minipage}{0.8\linewidth}%
            \scriptsize Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum \\
        \end{minipage}
    \end{table}
\end{landscape}
\end{document}
''''

答案1

也许你对以下布局更满意。在其中,我删除了命令resizeboxtabularx用常规tabulars 替换了环境,并稍微减少了\arraystretch。然而,第四个表的一些调整可能仍然需要。

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}% To set line spacing commands like \doublespacing
\usepackage{graphicx} %helps include \includegraphics
\usepackage{tikz} % To draw tikz pictures
\usepackage{pdflscape}
\usepackage{array}
\usepackage{tabularx} % To create panelled tables
\usepackage{booktabs}
\doublespacing

\begin{document}
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{landscape}

    \begin{table}[htbp]\renewcommand{\arraystretch}{1.2} 
        \caption{Table Caption Here}
        \label{panel_table}
        \centering
        %\resizebox{0.8\textwidth}{!}{%
            \begin{tabular}{l*{4}{r}}
                \toprule 
                \multicolumn{5}{c}{\textbf{Panel A}}\\
                \multicolumn{5}{c}{\textit{Dep. Var: } Some Dep Variable Here} \\\midrule

                &\multicolumn{2}{c}{Approach One} & \multicolumn{2}{c}{Approach Two} \\ 
                \cmidrule(lr){2-3}
                \cmidrule(lr){4-5} 

                &  \multicolumn{2}{c}{Citation for One}    &  \multicolumn{2}{c}{Citation for Two}\\ 
                & (1) & (2) & (3) & (4) \\ \midrule 
                Ind Variable &  1.1111*** & 1.1111**   & 1.1111**  & 1.1111**  \\
                &  (1.11111) & (1.11111)  & (1.11111) & (1.11111) \\  \midrule
                Observations & 5000 & 1,5000 & 1,5000 & 1,5000 \\ 
              \bottomrule   
            \end{tabular}\hfill
        %}
        %\resizebox{0.8\textwidth}{!}{%
        \begin{tabular}{l*{4}{r}}
            \toprule 
            \multicolumn{5}{c}{\textbf{Panel B}}\\
            \multicolumn{5}{c}{\textit{Dep. Var: } Some Dep Variable Here} \\\midrule

            &\multicolumn{2}{c}{Approach One} & \multicolumn{2}{c}{Approach Two} \\ 
            \cmidrule(lr){2-3}
            \cmidrule(lr){4-5} 

            &  \multicolumn{2}{c}{Citation for One}    &  \multicolumn{2}{c}{Citation for Two}\\ 
            & (1) & (2) & (3) & (4) \\ \midrule 
            Ind Variable &  1.1111*** & 1.1111**   & 1.1111**  & 1.1111**  \\
            &  (1.11111) & (1.11111)  & (1.11111) & (1.11111) \\  \midrule
            Observations & 5000 & 1,5000 & 1,5000 & 1,5000 \\ 
            \bottomrule 
        \end{tabular}
    %}

    %\resizebox{0.8\textwidth}{!}{%
    \begin{tabular}{l*{4}{r}}
        \toprule 

        \multicolumn{5}{c}{\textbf{Panel C}}\\
        \multicolumn{5}{c}{\textit{Dep. Var: } Some Dep Variable Here} \\\midrule

        &\multicolumn{2}{c}{Approach One} & \multicolumn{2}{c}{Approach Two} \\ 
        \cmidrule(lr){2-3}
        \cmidrule(lr){4-5} 

        &  \multicolumn{2}{c}{Citation for One}    &  \multicolumn{2}{c}{Citation for Two}\\ 
        & (1) & (2) & (3) & (4) \\ \midrule 
        Ind Variable &  1.1111*** & 1.1111**   & 1.1111**  & 1.1111**  \\
        &  (1.11111) & (1.11111)  & (1.11111) & (1.11111) \\  \midrule
        Observations & 5000 & 1,5000 & 1,5000 & 1,5000 \\ 
        \bottomrule 
    \end{tabular}\hfill
%}
%
        %\resizebox{0.8\textwidth}{!}{%
            \begin{tabular}{l*{3}{r}} \toprule
                \multicolumn{3}{c}{Panel D}\\
                Variables &\multicolumn{2}{c}{Another Dep Variable} \\ 
                & (1) & (2) \\\midrule
                genderquota & 1.1111*** & 1.1111**\\
                & (1.1111) & (1.1111) \\
                Constant & 1.1111*** & 1.1111**\\
                & (1.1111) & (1.1111)  \\\midrule
                Observations & 1,1212 & 1,123123 \\
                R-squared & 0.022 & 0.267 \\  
                 \bottomrule
        \end{tabular}% } 

        \begin{minipage}{\linewidth}%
        Standard errors in parentheses are clustered 

        *** p$<$0.01, ** p$<$0.05, * p$<$0.1

            \scriptsize Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum \\
        \end{minipage}
    \end{table}
\end{landscape}
\end{document}

答案2

我认为没有必要使用横向表,也不需要使用tabularxxltabularltablex)表环境。我还将使用包S中的列类型siunitx

\documentclass[11pt]{article}
\usepackage[%showframe,
            margin=1in]{geometry}
%\usepackage{setspace}% To set line spacing commands like \doublespacing
\usepackage{caption} %helps include \includegraphics
%\usepackage{pdflscape}
\usepackage{array, booktabs, longtable} % To create panelled tables
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{siunitx}

\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
    {\multicolumn{#1}{c}{#2}}

%\doublespacing

\begin{document}
%        \resizebox{0.8\textwidth}{!}{%
{
\sisetup{input-symbols = {()},
         round-integer-to-decimal,
         round-mode=places,
         round-precision=3,
         table-format=2.3,
         table-space-text-post=***}
\renewcommand{\arraystretch}{1.1}
%\setlength\tabcolsep{0pt}
    \begin{longtable}{l *{4}{S} }
\caption{Table Caption Here}
\label{panel_table}                                                 \\
    \toprule
    &   \mcc[2]{Approach One}       &   \mcc[2]{Approach Two}       \\
    \cmidrule(l){2-3}
    \cmidrule(l){4-5}
    &  \mcc[2]{Citation for One}    &   \mcc[2]{Citation for Two}   \\
    & {(1)}            & {(2)}      & {(3)}         & {(4)}         \\ 
    \midrule
\endfirsthead
\caption[]{Table Caption Here (Cont.)}                              \\
    \toprule
    &   \mcc[2]{Approach One}       &   \mcc[2]{Approach Two}       \\
    \cmidrule(l){2-3}
    \cmidrule(l){4-5}
    &  \mcc[2]{Citation for One}    &   \mcc[2]{Citation for Two}   \\
    & {(1)}            & {(2)}      & {(3)}         & {(4)}         \\
    \midrule
\endhead
    \midrule
\multicolumn{5}{r}{\footnotesize\textit{Continue on the next page}} \\
\endfoot
\endlastfoot
% table body
\mcc[5]{\textbf{Panel A}}                                           \\
\mcc[5]{\textbf{Dep. Var:} \textit{Some Dep Variable Here}}         \\
    \midrule
Ind Variable 
    &  1.1111***    &  1.1111**     &  1.1111** & 1.1111**          \\
    & (1.11111)     & (1.11111)     & (1.11111) & (1.11111)         \\  
    \midrule
Observations 
    & {5,000}       & {1,5000}      & {1,5000}  & {1,5000}          \\
    \midrule[\heavyrulewidth]
\mcc[5]{\textbf{Panel B}}                                           \\
\mcc[5]{\textit{Dep. Var: } Some Dep Variable Here}                 \\
    \midrule
Ind Variable
    &  1.1111***    &  1.1111**     &  1.1111** &  1.1111**         \\
    & (1.11111)     & (1.11111)     & (1.11111) & (1.11111)         \\  
    \midrule
Observations
    & {5,000}       & {1,5000}      & {1,5000}  & {1,5000}          \\
    \midrule
Ind Variable 
    &  1.1111***    &  1.1111**     & 1.1111**  & 1.1111**          \\
    & (1.11111)     & (1.11111)     & (1.11111) & (1.11111)         \\  
    \midrule
Observations 
    & 5,000         & 1,5000        & 1,5000    & 1,5000            \\
    \midrule[\heavyrulewidth]
\mcc[5]{\textbf{Panel D}}                                           \\
    \midrule
genderquota 
    & 1.1111***     & 1.1111**      &           &                   \\
    & (1.1111)      & (1.1111)      &           &                   \\
Constant 
    & 1.1111***     & 1.1111**      &           &                   \\
    & (1.1111)      & (1.1111)      &           &                   \\  
    \midrule
Observations 
    & 1,1212        & 1,123123      &           &                   \\
R-squared
    & 0.022         & 0.267         &           &                   \\  
    \bottomrule
\multicolumn{3}{l}{ Standard errors in parentheses are clustered}   \\
\multicolumn{5}{l}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.1}           \\
\end{longtable}
}
{    \scriptsize 
Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum 
}
\end{document}

在此处输入图片描述

相关内容