如何将表转换为长表

如何将表转换为长表

我有以下表格,其环境threeparttable无法放在一页上。我对我的所有 LaTeX 代码都非常满意,并且非常希望有一个解决方案,让我不需要更改表格内部或重新写入所有数字。

\documentclass[11pt]{article}

\usepackage{longtable}
\usepackage{amsmath}
\usepackage[T1]{fontenc}
\usepackage{booktabs, caption}
\usepackage[flushleft]{threeparttable}
\usepackage{tabularx}
\DeclareMathOperator*{\plim}{plim}
\begin{document}


\title{title}
\author{Author}
\date{\today}
\maketitle

    \begin{table}[p]
    \centering
      \begin{threeparttable}
        \caption{Pooled OLS and Fixed effects estimation on the initial model (eq. 1)}
         \begin{tabular}{llllll}
            \toprule
           \(Dependent variable: \Delta H_{it}\)  & \( Initial\ POLS \) & \( Initial\ FE \) & \ \\
            \midrule
                \\
    $Male$ & -.00154*** &  & &  &  \\
           & (.00033) &&&& \\
    $Age$ & .00195*** & .00094 &  &  &  \\
    & (.00069) & (.00113) &&& \\
    $Age^{2}$ & -.00002*** & -.00002*** &  &  &  \\
    & (.00000) & (.00000) &&& \\
    $Black$ & .00180*** &  &  & &  \\
    & (.00052) &&&& \\
    $Hispanic$ & .00095 &  &  & &  \\
    & (.00068) &&&& \\
    $Married/partner$ & -.00069*** & -.00357*** &  &  &  \\
    & (.00043) & (.00127) &&& \\
    $log(assets)$ & .00055*** & .00031* & 0.362 & 0 & 1 \\
    & (.00008) &(.00017) &&& \\
    $log(debt)$ & -.00016*** & -.00006 & 0.245 & 0 & 1 \\
    & (.00005) & (.00008)&&& \\
    $Some highschool$ & .00146** & &  &  &  \\
    & (.00063) &&&& \\
    $Highschool (GED)$ & .00120** &  &  & &  \\
    & (.00057) &&&& \\
    $AA$ & .00122 &  &  &  &  \\
    & (.00084) &&&& \\
    $Bachelor degree$ & .00228*** &  &  & &  \\
    & (.00067) &&&& \\
    $Graduate degree$ & .00287*** &  &  &  & \\
    & (.00067) &&&& \\
    $RS_{it}$* & -.00884*** & -.00717*** &  &  &  \\
    & (.00101) & (.00112) &&& \\
    $RL_{it}$ & -.00014 & .00135 &  &  &  \\
    & (.00051) & (.00089) &&& \\
    $Constant$ & -.07498*** & -.00814 &  & &  \\
    & (.02142) & (.04949) &&& \\
    \\
    $time$ & &  &  &  &  \\
    3 & .00209* & .00369* &  &  &  \\
    & (.00051) & (.00193) &&& \\
    4 & -.00717 & -.00398 &  &  &  \\
    & (.00104) & (.00323) &&& \\
    5 & .004299*** & .00950** &  &  &  \\
    & (.00097) & (.00468) &&& \\
    6 & -.00268*** & .00476 &  & &  \\
    & (.00100) & (.00636) &&& \\
    7 & -.00348*** & .00602 &  & & \\
    & (.00104) & (.00787) &&& \\
    8 & -.00000 & .01158 &  &  &  \\
    & (.00091) & (.00949) &&& \\
    9 & -.00327*** & .01006 &  &  &  \\
    & (.00095) & (.01099) &&& \\
    10 & -.00154 & .01719 &  &  &  \\
    & (.00100) & (.01278) &&& \\

                  \end{tabular}
               \begin{tablenotes}
            \small
          \item Notes:
          \item *: dummy variable estimates refer to sample                     proportions rather than averages
          \item A: Originally 1 - excellent, 2 - very good, 3 - good, 4 - fair, 5 - poor. Probit estimations did not work so I rescaled to 0 - poor, 0.25 - fair, 0.5 - good, 0.75 - very good, 1 - excellent
          \item B: See section 3.2
       \end{tablenotes}
     \end{threeparttable}
    \end{table}
end{document}

我也尝试过这个:

\documentclass[11pt]{article}

    \usepackage{longtable}
    \usepackage{amsmath}
    \usepackage[T1]{fontenc}
    \usepackage{booktabs, caption}
    \usepackage[flushleft]{threeparttable}
    \usepackage{tabularx}
    \DeclareMathOperator*{\plim}{plim}
    \begin{document}


    \title{title}
    \author{Author}
    \date{\today}
    \maketitle


        \begin{center}
        \begin{longtable}{|c|c|c|c|}

        \hline
        \textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
        \hline
        \endfirsthead
        \multicolumn{4}{c}%
        {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
        \hline
        \textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
        \hline
        \endhead
        \hline \multicolumn{4}{r}{\textit{Continued on next page}} \\
        \endfoot
        \hline
        \endlastfoot

          \begin{threeparttable}
            \caption{Pooled OLS and Fixed effects estimation on the initial model (eq. 1)}
             \begin{tabular}{llllll}
                \toprule
               \(Dependent variable: \Delta H_{it}\)  & \( Initial\ POLS \) & \( Initial\ FE \) & \ \\
                \midrule

                  \\
        $Male$ & -.00154*** &  & &  &  \\
               & (.00033) &&&& \\
        $Age$ & .00195*** & .00094 &  &  &  \\
        & (.00069) & (.00113) &&& \\
        $Age^{2}$ & -.00002*** & -.00002*** &  &  &  \\
        & (.00000) & (.00000) &&& \\
        $Black$ & .00180*** &  &  & &  \\
        & (.00052) &&&& \\
        $Hispanic$ & .00095 &  &  & &  \\
        & (.00068) &&&& \\
        $Married/partner$ & -.00069*** & -.00357*** &  &  &  \\
        & (.00043) & (.00127) &&& \\
        $log(assets)$ & .00055*** & .00031* & 0.362 & 0 & 1 \\
        & (.00008) &(.00017) &&& \\
        $log(debt)$ & -.00016*** & -.00006 & 0.245 & 0 & 1 \\
        & (.00005) & (.00008)&&& \\
        $Some highschool$ & .00146** & &  &  &  \\
        & (.00063) &&&& \\
        $Highschool (GED)$ & .00120** &  &  & &  \\
        & (.00057) &&&& \\
        $AA$ & .00122 &  &  &  &  \\
        & (.00084) &&&& \\
        $Bachelor degree$ & .00228*** &  &  & &  \\
        & (.00067) &&&& \\
        $Graduate degree$ & .00287*** &  &  &  & \\
        & (.00067) &&&& \\
        $RS_{it}$* & -.00884*** & -.00717*** &  &  &  \\
        & (.00101) & (.00112) &&& \\
        $RL_{it}$ & -.00014 & .00135 &  &  &  \\
        & (.00051) & (.00089) &&& \\
        $Constant$ & -.07498*** & -.00814 &  & &  \\
        & (.02142) & (.04949) &&& \\
        \\
        $time$ & &  &  &  &  \\
        3 & .00209* & .00369* &  &  &  \\
        & (.00051) & (.00193) &&& \\
        4 & -.00717 & -.00398 &  &  &  \\
        & (.00104) & (.00323) &&& \\
        5 & .004299*** & .00950** &  &  &  \\
        & (.00097) & (.00468) &&& \\
        6 & -.00268*** & .00476 &  & &  \\
        & (.00100) & (.00636) &&& \\
        7 & -.00348*** & .00602 &  & & \\
        & (.00104) & (.00787) &&& \\
        8 & -.00000 & .01158 &  &  &  \\
        & (.00091) & (.00949) &&& \\
        9 & -.00327*** & .01006 &  &  &  \\
        & (.00095) & (.01099) &&& \\
        10 & -.00154 & .01719 &  &  &  \\
        & (.00100) & (.01278) &&& \\

                  \end{tabular}


                   \begin{tablenotes}
                \small
              \item Notes:
              \item *: dummy variable estimates refer to sample                     proportions rather than averages
              \item A: Originally 1 - excellent, 2 - very good, 3 - good, 4 - fair, 5 - poor. Probit estimations did not work so I rescaled to 0 - poor, 0.25 - fair, 0.5 - good, 0.75 - very good, 1 - excellent
              \item B: See section 3.2
           \end{tablenotes}
         \end{threeparttable}


        \end{longtable}
        \end{center}

    \end{document}

答案1

longtable我向您展示了使用和编译来更改第二张表的可能性threeparttablex

请注意,我对您的表格文本代码进行了漂亮的打印,我建议获取一个表格代码,以便读者可以更好地理解并能够轻松找到需要更改的单元格...

因为您给出的代码似乎是多次尝试的混合,所以我只是缩短了您使用的单元格标题的长度。最后,您必须重新设计整个表格以满足您的需求。顺便说一句:表格中最后两列的标题丢失了。但以下是一个包​​含threeparttable与 结合的可编译的起点longtable

\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{longtable} % <==============================================
\usepackage[]{threeparttablex} % <======================================

\usepackage{amsmath}


\begin{document}

\title{title}
\author{Author}
\date{\today}
\maketitle

\begin{ThreePartTable}
%\renewcommand\TPTminimum{\textwidth}

\begin{TableNotes}
  \small
  \item Notes:
  \item *: dummy variable estimates refer to sample proportions rather than averages
  \item A: Originally 1 - excellent, 2 - very good, 3 - good, 4 - fair, 
    5 - poor. Probit estimations did not work so I rescaled to 0 - poor, 
    0.25 - fair, 0.5 - good, 0.75 - very good, 1 - excellent
  \item B: See section 3.2
\end{TableNotes}

\begin{longtable}{llllll}
  \caption{Pooled OLS and Fixed effects estimation on the initial model (eq. 1)}\label{tab:OLS}\\
  \toprule
  \textbf{Dependent:}          & \textbf{Initial} & \textbf{Initial} & \textbf{Fourth} & 5 & 6\\
  \textbf{$\Delta H_{it}$}     & \textbf{POLS}    & \textbf{FE}      & \textbf{Fourth} & & \\
  \midrule
\endfirsthead
  \multicolumn{6}{c}%
    {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
  \toprule
  \textbf{Dependent:}          & \textbf{Initial} & \textbf{Initial} & \textbf{Fourth} & 5 & 6\\
  \textbf{$\Delta H_{it}$}     & \textbf{POLS}    & \textbf{FE}      & \textbf{Fourth} & & \\
  \midrule
\endhead
  \midrule 
  \multicolumn{6}{r}{\textit{Continued on next page}} \\
\endfoot
  \bottomrule
  \insertTableNotes % <========== tell LaTeX where to insert the table-related notes
\endlastfoot
  Male               & -.00154*** &            &       &   &  \\
                     & (.00033)   &            &       &   & \\
  Age                & .00195***  & .00094     &       &   &  \\
                     & (.00069)   & (.00113)   &       &   & \\
  Age$^{2}$          & -.00002*** & -.00002*** &       &   &  \\
                     & (.00000)   & (.00000)   &       &   & \\
  Black              & .00180***  &            &       &   &  \\
                     & (.00052)   &            &       &   & \\
  Hispanic           & .00095     &            &       &   &  \\
                     & (.00068)   &            &       &   & \\
  Married/partner    & -.00069*** & -.00357*** &       &   &  \\
                     & (.00043)   & (.00127)   &       &   & \\
  log(assets)        & .00055***  & .00031*    & 0.362 & 0 & 1 \\
                     & (.00008)   &(.00017)    &       &   & \\
  log(debt)          & -.00016*** & -.00006    & 0.245 & 0 & 1 \\
                     & (.00005)   & (.00008)   &       &   & \\
  Some highschool    & .00146**   &            &       &   &  \\
                     & (.00063)   &            &       &   & \\
  Highschool (GED)   & .00120**   &            &       &   &  \\
                     & (.00057)   &            &       &   & \\
  AA                 & .00122     &            &       &   &  \\
                     & (.00084)   &            &       &   & \\
  Bachelor degree    & .00228***  &            &       &   &  \\
                     & (.00067)   &            &       &   & \\
  Graduate degree    & .00287***  &            &       &   & \\
                     & (.00067)   &            &       &   & \\
  RS$_{it}$*         & -.00884*** & -.00717*** &       &   &  \\
                     & (.00101)   & (.00112)   &       &   & \\
  RL$_{it}$          & -.00014    & .00135     &       &   &  \\
                     & (.00051)   & (.00089)   &       &   & \\
  Constant           & -.07498*** & -.00814    &       &   &  \\
                     & (.02142)   & (.04949)   &       &   & \\
  \midrule
  time               &            &            &       &   &  \\
  3                  & .00209*    & .00369*    &       &   &  \\
                     & (.00051)   & (.00193)   &       &   & \\
  4                  & -.00717    & -.00398    &       &   &  \\
                     & (.00104)   & (.00323)   &       &   & \\
  5                  & .004299*** & .00950**   &       &   &  \\
                     & (.00097)   & (.00468)   &       &   & \\
  6                  & -.00268*** & .00476     &       &   &  \\
                     & (.00100)   & (.00636)   &       &   & \\
  7                  & -.00348*** & .00602     &       &   & \\
                     & (.00104)   & (.00787)   &       &   & \\
  8                  & -.00000    & .01158     &       &   &  \\
                     & (.00091)   & (.00949)   &       &   & \\
  9                  & -.00327*** & .01006     &       &   &  \\
                     & (.00095)   & (.01099)   &       &   & \\
  10                 & -.00154    & .01719     &       &   &  \\
                     & (.00100)   & (.01278)   &       &   & \\
\end{longtable}
\end{ThreePartTable}

\end{document}

导致:

第一页

第二页:

第二页

相关内容