将长表格分成 2 页

将长表格分成 2 页

我有一张很长的表格,想把它分成两页,我想在第一页上写“待续”,在第二页上写“从上一张表格继续”。我知道我必须在某处使用 \endhead 和 \endfirsthead 代码,但我不知道在哪里。


\documentclass[12pt,twoside]{report}

\usepackage{tabularx, booktabs,multirow,adjustbox,caption,float,subcaption, longtable}

\begin{document}

{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{spacing}{1.03}
\begin{longtable}{l*{1}{c}} 
\caption{Executive Constraints by Regime Type} \label{Tab:Tab 2}\\
\hline\hline\endfirsthead\hline\endhead\hline\endfoot\endlastfoot
                    &\multicolumn{1}{c}{(1)}\\
                    &\multicolumn{1}{c}{mean(sd)}\\
\hline
\textbf{Civilian Dictatorship}            &                     \\
Legislative constraints on the executive index&       0.300         \\
                    &     (0.240)         \\

Judicial constraints on the executive index&       0.364         \\
                    &     (0.246)         \\

Range of consultation&     -0.0467         \\
                    &     (1.034)         \\

Party institutionalization index&       0.502         \\
                    &     (0.223)         \\

Freedom of Expression and Alternative Sources of Information index&       0.367         \\
                    &     (0.258)         \\

Relative Experience of Core Cabinet Members          &       1.029         \\
                    &     (1.119)        
\\\hline
%
\textbf{Democracy}           &                     \\
Legislative constraints on the executive index&       0.749         \\
                    &     (0.213)         \\

Judicial constraints on the executive index&       0.770         \\
                    &     (0.205)         \\

Range of consultation&       1.560         \\
                    &     (1.020)         \\

Party institutionalization index&       0.736         \\
                    &     (0.223)         \\

Freedom of Expression and Alternative Sources of Information index&       0.850         \\
                    &     (0.136)         \\

Relative Experience of Core Cabinet Members             &       1.413         \\
                    &     (1.123)         \\
\hline
\textbf{Military Dictatorship}            &                     \\
Legislative constraints on the executive index&       0.202         \\
                    &     (0.184)         \\

Judicial constraints on the executive index&       0.270         \\
                    &     (0.201)         \\

Range of consultation&      -0.619         \\
                    &     (1.041)         \\

Party institutionalization index&       0.431         \\
                    &     (0.201)         \\

Freedom of Expression and Alternative Sources of Information index&       0.279         \\
                    &     (0.222)         \\

Relative Experience of Core Cabinet Members            &       0.843         \\
                    &     (0.866)         \\
\hline
\textbf{Royal Dictatorship}               &                     \\
Legislative constraints on the executive index&       0.287         \\
                    &     (0.254)         \\

Judicial constraints on the executive index&       0.410         \\
                    &     (0.224)         \\

Range of consultation&      -0.174         \\
                    &     (0.923)         \\

Party institutionalization index&       0.158         \\
                    &     (0.170)         \\

Freedom of Expression and Alternative Sources of Information index&       0.268         \\
                    &     (0.199)         \\

Relative Experience of Core Cabinet Members             &       0.981         \\
                    &     (1.355)         \\
\hline

\hline\hline
\multicolumn{2}{l}{\footnotesize mean coefficients; sd in parentheses}\\
\end{longtable}
\end{spacing}
}

\end{document}```

答案1

\documentclass[12pt,twoside]{report}

\usepackage{tabularx, booktabs,multirow,adjustbox,caption,float,subcaption, longtable}

\begin{document}

{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
%\begin{spacing}{1.03} %commented as not defined in the code
\begin{longtable}{l*{1}{c}} 
\caption{Executive Constraints by Regime Type} \label{Tab:Tab 2}\\
\hline
                    &\multicolumn{1}{c}{(1)}\\
                    &\multicolumn{1}{c}{mean(sd)}\\
\hline
\endfirsthead

\multicolumn{2}{c}{continued from the last table}\\
\hline
                    &\multicolumn{1}{c}{(1)}\\
                    &\multicolumn{1}{c}{mean(sd)}\\
\hline
\endhead

\hline\hline\multicolumn{2}{l}{\footnotesize mean coefficients; sd in parentheses}\\
\multicolumn{2}{r}{{to be continued}}
\endfoot

\hline\hline\multicolumn{2}{l}{\footnotesize mean coefficients; sd in parentheses}
\endlastfoot

\textbf{Civilian Dictatorship}            &                     \\
Legislative constraints on the executive index&       0.300         \\
                    &     (0.240)         \\

Judicial constraints on the executive index&       0.364         \\
                    &     (0.246)         \\

Range of consultation&     -0.0467         \\
                    &     (1.034)         \\

Party institutionalization index&       0.502         \\
                    &     (0.223)         \\

Freedom of Expression and Alternative Sources of Information index&       0.367         \\
                    &     (0.258)         \\

Relative Experience of Core Cabinet Members          &       1.029         \\
                    &     (1.119)        
\\\hline
%
\textbf{Democracy}           &                     \\
Legislative constraints on the executive index&       0.749         \\
                    &     (0.213)         \\

Judicial constraints on the executive index&       0.770         \\
                    &     (0.205)         \\

Range of consultation&       1.560         \\
                    &     (1.020)         \\

Party institutionalization index&       0.736         \\
                    &     (0.223)         \\

Freedom of Expression and Alternative Sources of Information index&       0.850         \\
                    &     (0.136)         \\

Relative Experience of Core Cabinet Members             &       1.413         \\
                    &     (1.123)         \\
\hline
\textbf{Military Dictatorship}            &                     \\
Legislative constraints on the executive index&       0.202         \\
                    &     (0.184)         \\

Judicial constraints on the executive index&       0.270         \\
                    &     (0.201)         \\

Range of consultation&      -0.619         \\
                    &     (1.041)         \\

Party institutionalization index&       0.431         \\
                    &     (0.201)         \\

Freedom of Expression and Alternative Sources of Information index&       0.279         \\
                    &     (0.222)         \\

Relative Experience of Core Cabinet Members            &       0.843         \\
                    &     (0.866)         \\
\hline
\textbf{Royal Dictatorship}               &                     \\
Legislative constraints on the executive index&       0.287         \\
                    &     (0.254)         \\

Judicial constraints on the executive index&       0.410         \\
                    &     (0.224)         \\

Range of consultation&      -0.174         \\
                    &     (0.923)         \\

Party institutionalization index&       0.158         \\
                    &     (0.170)         \\

Freedom of Expression and Alternative Sources of Information index&       0.268         \\
                    &     (0.199)         \\

Relative Experience of Core Cabinet Members             &       0.981         \\
                    &     (1.355)         \\
\hline
\end{longtable}
%\end{spacing}
}

\end{document}

在此处输入图片描述

在此处输入图片描述

答案2

虽然不完全符合您的要求,但如果您稍微重新设计一下,就可以很容易地将整个表格放到一页上:

在此处输入图片描述

\documentclass[12pt,twoside]{report}

\usepackage{booktabs}
\usepackage{caption}
\usepackage{xltabular}
\usepackage{siunitx}
\begin{document}

\begin{table}
\caption{Executive Constraints by Regime Type}
\label{Tab:Tab 2}
\begin{tabularx}{\linewidth}{>{\small}XS[table-format=-1.4]c} 
\toprule
                    & \multicolumn{2}{c}{(1)}\\
\cmidrule{2-3}
                    & {mean} & {(sd)} \\
\midrule

\multicolumn{3}{@{}l}{\textbf{Civilian Dictatorship}}                                  \\
Legislative constraints on the executive index                     &  0.300  & (0.240) \\
Judicial constraints on the executive index                        &  0.364  & (0.246) \\
Range of consultation                                              & -0.0467 & (1.034) \\
Party institutionalization index                                   &  0.502  & (0.223) \\
Freedom of Expression and Alternative Sources of Information index &  0.367  & (0.258) \\
Relative Experience of Core Cabinet Members                        &  1.029  & (1.119) \\
\midrule
\multicolumn{3}{@{}l}{\textbf{Democracy}}                                              \\
Legislative constraints on the executive index                     &  0.749  & (0.213) \\
Judicial constraints on the executive index                        &  0.770  & (0.205) \\
Range of consultation                                              &  1.560  & (1.020) \\
Party institutionalization index                                   &  0.736  & (0.223) \\
Freedom of Expression and Alternative Sources of Information index &  0.850  & (0.136) \\
Relative Experience of Core Cabinet Members                        &  1.413  & (1.123) \\
\midrule
\multicolumn{3}{@{}l}{\textbf{Military Dictatorship}}                                  \\
Legislative constraints on the executive index                     &  0.202  & (0.184) \\
Judicial constraints on the executive index                        &  0.270  & (0.201) \\
Range of consultation                                              & -0.619  & (1.041) \\
Party institutionalization index                                   &  0.431  & (0.201) \\
Freedom of Expression and Alternative Sources of Information index &  0.279  & (0.222) \\
Relative Experience of Core Cabinet Members                        &  0.843  & (0.866) \\
\midrule
\multicolumn{3}{@{}l}{\textbf{Royal Dictatorship}}                                     \\
Legislative constraints on the executive index                     &  0.287  & (0.254) \\
Judicial constraints on the executive index                        &  0.410  & (0.224) \\
Range of consultation                                              & -0.174  & (0.923) \\
Party institutionalization index                                   &  0.158  & (0.170) \\
Freedom of Expression and Alternative Sources of Information index &  0.268  & (0.199) \\
Relative Experience of Core Cabinet Members                        &  0.981  & (1.355) \\
\bottomrule
\end{tabularx}
\end{table}


\end{document}

答案3

这是我使用 xltabular 包的建议:

\documentclass[12pt,twoside]{report}

\usepackage{tabularx, booktabs,multirow,adjustbox,caption,float,subcaption, longtable}
\usepackage{xltabular}

\begin{document}

\newcolumntype{C}{>{\footnotesize\centering\arraybackslash}X}
\newcolumntype{L}{>{\footnotesize\raggedright\arraybackslash}X}


\begin{xltabular}{\textwidth} {
    >{\hsize=1.70\hsize}L
    >{\hsize=0.30\hsize}C
}

    \caption{Executive Constraints by Regime Type} \label{Tab:Tab 2}\\

    \toprule
    & (1)\\
    & mean(sd)\\ 
    \toprule
    \endfirsthead
        
    \multicolumn{2}{c}%
    {\tablename\ \thetable{}: {Continue from the previuos page.\vspace{0.3cm}}} \\
    \toprule
    & (1)\\
    & mean(sd)\\ 
    \toprule
    \endhead
        
    \midrule
    \multicolumn{2}{r}{\footnotesize\textit{Continue to the next page.}} 
    \endfoot
        
    \endlastfoot
    


\textbf{Civilian Dictatorship} & \\
Legislative constraints on the executive index&       0.300         \\
                    &     (0.240)         \\

Judicial constraints on the executive index&       0.364         \\
                    &     (0.246)         \\

Range of consultation&     -0.0467         \\
                    &     (1.034)         \\

Party institutionalization index&       0.502         \\
                    &     (0.223)         \\

Freedom of Expression and Alternative Sources of Information index&       0.367         \\
                    &     (0.258)         \\

Relative Experience of Core Cabinet Members          &       1.029         \\
                    &     (1.119)        
\\\midrule
%
\textbf{Democracy}           &                     \\
Legislative constraints on the executive index&       0.749         \\
                    &     (0.213)         \\

Judicial constraints on the executive index&       0.770         \\
                    &     (0.205)         \\

Range of consultation&       1.560         \\
                    &     (1.020)         \\

Party institutionalization index&       0.736         \\
                    &     (0.223)         \\

Freedom of Expression and Alternative Sources of Information index&       0.850         \\
                    &     (0.136)         \\

Relative Experience of Core Cabinet Members             &       1.413         \\
                    &     (1.123)         \\
\midrule
\textbf{Military Dictatorship}            &                     \\
Legislative constraints on the executive index&       0.202         \\
                    &     (0.184)         \\

Judicial constraints on the executive index&       0.270         \\
                    &     (0.201)         \\

Range of consultation&      -0.619         \\
                    &     (1.041)         \\

Party institutionalization index&       0.431         \\
                    &     (0.201)         \\

Freedom of Expression and Alternative Sources of Information index&       0.279         \\
                    &     (0.222)         \\

Relative Experience of Core Cabinet Members            &       0.843         \\
                    &     (0.866)         \\
\midrule
\textbf{Royal Dictatorship}               &                     \\
Legislative constraints on the executive index&       0.287         \\
                    &     (0.254)         \\

Judicial constraints on the executive index&       0.410         \\
                    &     (0.224)         \\

Range of consultation&      -0.174         \\
                    &     (0.923)         \\

Party institutionalization index&       0.158         \\
                    &     (0.170)         \\

Freedom of Expression and Alternative Sources of Information index&       0.268         \\
                    &     (0.199)         \\

Relative Experience of Core Cabinet Members             &       0.981         \\
                    &     (1.355)         \\


\bottomrule
\multicolumn{2}{l}{\footnotesize mean coefficients; sd in parentheses}\\
\end{xltabular}

\end{document}

在此处输入图片描述 在此处输入图片描述

答案4

我知道我必须在某处使用\endhead和 [ \endfoot] 代码,但我不知道在哪里。

我建议您使用类似下面的方法:

Table \thetable, cont'd from preceding page\\
\hline
\endhead

\hline
\multicolumn{2}{r@{}}{\small\itshape cont'd on next page}
\endfoot

完整的 MWE:

在此处输入图片描述

...

在此处输入图片描述

\documentclass[12pt,twoside]{report}

\usepackage{booktabs,longtable,setspace}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\begin{document}

\begin{spacing}{1}
\begin{longtable}{@{} l d{2.4} @{}} 
\caption{Executive Constraints by Regime Type} \label{Tab:Tab 2}\\
\toprule
    & \multicolumn{1}{c@{}}{(1)}\\
    & \multicolumn{1}{c@{}}{mean (sd)}\\
\midrule
\endfirsthead

Table \thetable, cont'd from preceding page\\
\midrule
\endhead

\midrule
\multicolumn{2}{r@{}}{\small\itshape cont'd on next page}
\endfoot

\bottomrule
\endlastfoot



\textbf{Civilian Dictatorship}      & \\
Legislative constraints on the executive index& 0.300 \\
          &   (0.240) \\

Judicial constraints on the executive index& 0.364 \\
          &   (0.246) \\

Range of consultation&   -0.0467 \\
          &   (1.034) \\

Party institutionalization index& 0.502 \\
          &   (0.223) \\

Freedom of Expression and Alternative Sources of Information index& 0.367 \\
          &   (0.258) \\

Relative Experience of Core Cabinet Members     & 1.029 \\
          &   (1.119) \\
 \addlinespace

\textbf{Democracy}      & \\
Legislative constraints on the executive index& 0.749 \\
          &   (0.213) \\

Judicial constraints on the executive index& 0.770 \\
          &   (0.205) \\

Range of consultation& 1.560 \\
          &   (1.020) \\

Party institutionalization index& 0.736 \\
          &   (0.223) \\

Freedom of Expression and Alternative Sources of Information index& 0.850 \\
          &   (0.136) \\

Relative Experience of Core Cabinet Members       & 1.413 \\
          &   (1.123) \\
 \addlinespace

\textbf{Military Dictatorship}      & \\
Legislative constraints on the executive index& 0.202 \\
          &   (0.184) \\

Judicial constraints on the executive index& 0.270 \\
          &   (0.201) \\

Range of consultation&   -0.619 \\
          &   (1.041) \\

Party institutionalization index& 0.431 \\
          &   (0.201) \\

Freedom of Expression and Alternative Sources of Information index& 0.279 \\
          &   (0.222) \\

Relative Experience of Core Cabinet Members      & 0.843 \\
          &   (0.866) \\
 \addlinespace

\textbf{Royal Dictatorship} & \\
Legislative constraints on the executive index& 0.287 \\
          &   (0.254) \\

Judicial constraints on the executive index& 0.410 \\
          &   (0.224) \\

Range of consultation&   -0.174 \\
          &   (0.923) \\

Party institutionalization index& 0.158 \\
          &   (0.170) \\

Freedom of Expression and Alternative Sources of Information index& 0.268 \\
          &   (0.199) \\

Relative Experience of Core Cabinet Members       & 0.981 \\
          &   (1.355) \\

\midrule
\multicolumn{2}{@{}l}{\footnotesize mean coefficients; sd in parentheses}\\

\end{longtable}
\end{spacing}

\end{document}

相关内容