如何将 tabular 转换为 longtable?典型的建议不起作用

如何将 tabular 转换为 longtable?典型的建议不起作用

我见过类似的问题,答案通常说我只需要做三件事:(i)删除 begin 和 end table,(ii)用 begin 和 end longtable 替换 begin 和 end tabular,(iii)加载 longtable 包。

当我将这 3 个步骤应用于以下代码时,它仍然不起作用?我还需要做其他调整吗?

%%% 01. LOADING PACKAGES
\documentclass[a4paper, 8pt]{article}
\usepackage{geometry}
\usepackage{array}
\usepackage{fancyhdr}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{indentfirst}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
%\usepackage{euler}
\usepackage{bm}
\usepackage{econometrics}
\usepackage{booktabs}
\usepackage{amsfonts, empheq, mathrsfs}
\usepackage[dvipsnames]{xcolor}
\usepackage{extsizes}

%%% 02. CUSTOMISING FORMAT
\renewcommand{\baselinestretch}{1.3}
\setlength{\parskip}{1em}
\setlength{\skip\footins}{2cm}
\setlength{\footnotesep}{0.5cm}

%%% 03. POPULATING TEXT FIELDS
\title{S140 Behavioural Economics}
\author{}
\date{}

%%% 04. PRODUCING PERSONALIZED COMMANDS
\newcommand{\xb}[1]{\pmb{#1}}
\newcommand{\xbh}[1]{\pmb{\hat{#1}}}
\newcommand{\xbi}[1]{\pmb{{#1}^{-1}}}
\newcommand{\xbt}[1]{\pmb{{#1}^{'}}}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\newcommand{\fconcepts}[1]{\textcolor{blue}{#1}}
\newcommand{\fquestions}[1]{\textcolor{red}{#1}}

%%% 05. TYPESETTING DOCUMENT
\begin{document}

        \newgeometry{top=0.5cm, bottom=0.5cm, left=0.5cm, right=0.5cm, asymmetric}
        \begin{landscape}
        
        \begin{table}[h!]
            \section{Overview of papers}
            
            \resizebox{\columnwidth}{!}{
                \begin{tabular}{|m{3.5cm}|m{9cm}|m{9cm}|m{17cm}|m{7cm}|}
                    \hline
                    \textbf{Paper}&\textbf{Objective}&\textbf{Methodology}&\textbf{Findings}&\textbf{Caveats}\\
                    \hline
                    
                    
                    \textbf{01. Roth et al. (1991):}
                    
                    Bargaining and Market Behavior, An Experimental Study
                    %OBJECTIVE
                    & 
                    \begin{itemize}
                        \item The three main goals were (i) to compare behaviour in related bargaining and market environments, (ii) to compare behavior in very different subject pools, and (iii) to use such differences to study out-of-equilibrium behaviour. 
                        \item Another important methodological goal was to learn how to deal with experimental design problems associated with multinational experiments, such that factors like language or currency could be controlled for, and cultural differences can be analyzed.
                    \end{itemize}
                    %METHODOLOGY
                    &
                    \begin{itemize}
                        \item Bargaining: Ultimatum game, two players, one makes a proposed division of the sum, the other can accept (and earn the proposed share) or reject (and both get zero). Ten sessions.
                        \item Market: Buyers submit offer to single seller, for object worth same amount to every buyer, and nothing to seller. Seller can either accept the highest price offered (receiving that amount, with buyer receiving the object’s value minus that amount, and others receiving zero) or reject it (all get zero). Ten markets.
                        \item Authors controlled for experimenter (ran experiences in Pittsburgh), language (translator national of relevant country), and currency (tokens as currency) effects.
                    \end{itemize}
                    %FINDINGS
                    &
                    \begin{enumerate}
                        \item Theoretical equilibrium: one player receives all the wealth (in the bargaining, the player who proposes the division; in the market, the seller).
                        \item Market environment: the observed market outcomes converge quickly to the perfect equilibrium, and do not deviate once reached, with no payoff-relevant differences observed between countries.
                        \item Bargaining environment: the observed bargaining outcomes are significantly different from the equilibrium predictions, with substantial differences between countries.
                        \item Offer and probability of acceptance: within every country these two variables were inversely related (low offers rejected more frequently than high offers), but the same does not hold across countries (higher disagreement not observed in countries with lower offers).
                        \item Role of experience in between-country differences: as subjects gained experience, between-country differences in market outcomes became smaller, while in bargaining outcomes they grew larger. This supports the view that differences in bargaining behaviour are not due to differences in languages, currencies, or experimenters, but other causes. 
                        \item Role of culture: culture is offered as a source of observed subject-pool differences, and authors suggest laboratory experimentation as a path for future research.
                    \end{enumerate}
                    
                    \fconcepts{\underline{Key concepts:}
                    \begin{itemize}
                        \item -
                    \end{itemize}}
                    %CAVEATS
                    &
                    \begin{enumerate}
                        \item Much higher percentage of army veterans in Israel and Yugoslavia than US or Japan.
                        \item Subjects were economics/business/psychology students, so sample is arguably contaminated.
                        \item Relatively small sample sizes.
                    \end{enumerate}
                
                    \fquestions{\underline{Questions:}
                    \begin{itemize}
                    \item What are the implications of changing the experiment from $10 to $30? Why would this change how subjects behave?
                    \end{itemize}}
                    \\
                    
                \hline
                    
            \end{tabular}
            }
        \end{table}
        \end{landscape}
                     
    
        
\end{document}

答案1

除了将嵌套的table/tabular环境更改为单个longtable环境之外,您还必须(正如@DavidCarlisle 已经指出的那样)摆脱包装器,\resisebox以便(a)在需要时进行分页,以及(b)避免以微小的字体大小排版材料。请记住:基本文档字体大小是8pt——您真的不想比这更小,除非你只是鄙视你的读者并希望让他们对你的报纸的享受比零更糟糕......

接下来,请用更合理的选择来替换超大的列宽——真的有 17 厘米吗?!此外,由于您的代码enumitem无论如何都会加载包,因此您不妨使用该包的\newlist\setlist指令来创建比默认环境更紧凑的enumerateitemize环境的变体。(请参阅下面的代码以获取一些具体建议。)最后,请考虑通过删除所有垂直线并使用包的宏booktabs而不是来为表格提供更开放的“外观” \hline

在此处输入图片描述

\documentclass[a4paper, 8pt]{extarticle}
\usepackage{geometry}
\usepackage{array}
\usepackage{fancyhdr}
\usepackage{amsmath, amsthm, amssymb}
%%\usepackage{graphicx} % 'rotating' loads 'graphicx' automatically
\usepackage{indentfirst}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
%\usepackage{euler}
\usepackage{bm}
\usepackage{econometrics}
\usepackage{booktabs}
\usepackage{%%amsfonts, % 'amssymb' loads 'amsfonts' automatically
    empheq, mathrsfs}
\usepackage[dvipsnames]{xcolor}
%%\usepackage{extsizes} % load 'extarticle' document class instead
\usepackage{hyperref}


%%% 02. CUSTOMISE FORMAT
%%\renewcommand{\baselinestretch}{1.3} % don't manipulate '\baselinestretch' directly
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.3}

\setlength{\parskip}{1em}
\setlength{\skip\footins}{1cm}
\setlength{\footnotesep}{0.5cm}

%%% 03. POPULATE TEXT FIELDS
\title{S140 Behavioural Economics}
\author{}
\date{}

%%% 04. PRODUCE PERSONALIZED COMMANDS
\newcommand{\xb}[1]{\pmb{#1}}
\newcommand{\xbh}[1]{\pmb{\hat{#1}}}
\newcommand{\xbi}[1]{\pmb{{#1}^{-1}}}
\newcommand{\xbt}[1]{\pmb{{#1}^{'}}}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\newcommand{\fconcepts}[1]{\textcolor{blue}{#1}}
\newcommand{\fquestions}[1]{\textcolor{red}{#1}}

%%% new code
\usepackage[normalem]{ulem} % for \uline macro
\usepackage{longtable,ragged2e}
\newlist{myitemize}{itemize}{1}
\setlist[myitemize,1]{label=\textbullet, leftmargin=*, nosep,
          before={\begin{minipage}[t]{\hsize}},
          after={\end{minipage}}}
\newlist{myenumerate}{enumerate}{1}
\setlist[myenumerate,1]{label=\arabic*., leftmargin=*, nosep,
          before={\begin{minipage}[t]{\hsize}},
          after={\end{minipage}}}
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}}

%%% 05. TYPESET DOCUMENT

\begin{document}

\newgeometry{margin=5mm, asymmetric}

\begin{landscape}
\section{Overview of papers}

\begingroup
\setstretch{1.0} % revert to single-spacing 
\begin{longtable}{P{3cm}P{5cm}P{5cm}P{8cm}P{5cm}}

\toprule
\textbf{Paper}&\textbf{Objective}&\textbf{Methodology}&\textbf{Findings}&\textbf{Caveats}\\
\midrule
\endhead

\midrule
\multicolumn{5}{r@{}}{\small\em continued on following page}
\endfoot

\bottomrule
\endlastfoot

%% Body of table
                    
01.\ Roth et al.\ (1991)
                    
Bargaining and Market Behavior, An Experimental Study &

%OBJECTIVE
\begin{myitemize}
\item The three main goals were (i) to compare behaviour in related bargaining and market environments, (ii) to compare behavior in very different subject pools, and (iii)~to use such differences to study out-of-equilibrium behaviour. 
\item Another important methodological goal was to learn how to deal with experimental design problems associated with multinational experiments, such that factors like language or currency could be controlled for, and cultural differences can be analyzed.
\end{myitemize} &

%METHODOLOGY
\begin{myitemize}
\item Bargaining: Ultimatum game, two players, one makes a proposed division of the sum, the other can accept (and earn the proposed share) or reject (and both get zero). 

Ten sessions.
\item Market: Buyers submit offer to single seller, for object worth same amount to every buyer, and nothing to seller. Seller can either accept the highest price offered (receiving that amount, with buyer receiving the object's value minus that amount, and others receiving zero) or reject it (all get zero). 

Ten markets.
\item Authors controlled for experimenter (ran experiences in Pittsburgh), language (translator national of relevant country), and currency (tokens as currency) effects.
\end{myitemize} &

%FINDINGS
\begin{myenumerate}
\item Theoretical equilibrium: one player receives all the wealth (in the bargaining, the player who proposes the division; in the market, the seller).
\item Market environment: the observed market outcomes converge quickly to the perfect equilibrium, and do not deviate once reached, with no payoff-relevant differences observed between countries.
\item Bargaining environment: the observed bargaining outcomes are significantly different from the equilibrium predictions, with substantial differences between countries.
\item Offer and probability of acceptance: within every country these two variables were inversely related (low offers rejected more frequently than high offers), but the same does not hold across countries (higher disagreement not observed in countries with lower offers).
\item Role of experience in between-country differences: as subjects gained experience, between-country differences in market outcomes became smaller, while in bargaining outcomes they grew larger. This supports the view that differences in bargaining behaviour are not due to differences in languages, currencies, or experimenters, but other causes. 
\item Role of culture: culture is offered as a source of observed subject-pool differences, and authors suggest laboratory experimentation as a path for future research.
\end{myenumerate}
                    
\bigskip
\fconcepts{\uline{Key concepts}}
\begin{myitemize} \color{blue}
\item --
\end{myitemize}  &

%CAVEATS
\begin{myenumerate}
\item Much higher percentage of army veterans in Israel and Yugoslavia than US or Japan.
\item Subjects were economics\slash business\slash psychology students, so sample is arguably contaminated.
\item Relatively small sample sizes.
\end{myenumerate}
                
\bigskip
\fquestions{\uline{Questions}}
\begin{myitemize} \color{red}
\item What are the implications of changing the experiment from $10$ to $30$? Why would this change how subjects behave?
\end{myitemize}
\\
                    
\end{longtable}
\endgroup


\end{landscape}     
        
\end{document}

答案2

对 @Mico 的精彩回答的补充 (+1)。使用 package amd 时,定义命令和tabularray会略有不同。\fconcepts\fquestions

在序言中仅考虑与表格相关的内容。

\documentclass[a4paper, 8pt]{extarticle}
\usepackage{geometry}
\usepackage{pdflscape}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.3}

\usepackage{bm}
\usepackage{microtype}  % new

\usepackage{enumitem}
\newlist{tabitem}{itemize}{1}
\setlist[tabitem,1]{nosep,
                    parsep=0.5ex, % added
                    label=\textbullet, 
                    leftmargin=*,
                    before=\begin{minipage}[t]{\linewidth},
                    after =\end{minipage}
                    }
\newlist{tabenum}{enumerate}{1}
\setlist[tabenum,1]{nosep,
                    parsep=0.5ex, % added
                    label=\arabic*., 
                    leftmargin=*, 
                    before=\begin{minipage}[t]{\hsize},
                    after =\end{minipage}
                    }
\usepackage{econometrics}
\usepackage[normalem]{ulem} % for \uline macro
\newcommand{\fconcepts}[2]{\color{blue}{#1}\par #2} % changed
\newcommand{\fquestions}[2]{\color{red}{#1}\par #2} % changed

\usepackage[dvipsnames]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, varwidth}

\begin{document}
\newgeometry{margin=5mm, asymmetric}
\begin{landscape}
\setstretch{1.0} % revert to single-spacing
    \begin{longtblr}[
caption = {Overview of papers},
  label = {tab:papers}
                    ]{colspec = {@{} X[0.6,j] X[j] X[j] X[1.6,j]  X [j] },
                       row{1} = {font=\bfseries, c},
                      measure = vbox,
                     }
    \toprule
Paper
    &   Objective
        &   Methodology
            &   Findings
                &   Caveats             \\
    \midrule
%% Body of table
01.\ Roth et al.\ (1991)

Bargaining and Market Behavior, An Experimental Study
    &   %OBJECTIVE
        \begin{tabitem}
    \item   The three main goals were (i) to compare behaviour in related bargaining and market environments, (ii) to compare behavior in very different subject pools, and (iii)~to use such differences to study out-of-equilibrium behaviour.
    \item   Another important methodological goal was to learn how to deal with experimental design problems associated with multinational experiments, such that factors like language or currency could be controlled for, and cultural differences can be analyzed.
        \end{tabitem}
        &   %METHODOLOGY
            \begin{tabitem}
        \item Bargaining: Ultimatum game, two players, one makes a proposed division of the sum, the other can accept (and earn the proposed share) or reject (and both get zero).

            \emph{Ten sessions.}
        \item Market: Buyers submit offer to single seller, for object worth same amount to every buyer, and nothing to seller. Seller can either accept the highest price offered (receiving that amount, with buyer receiving the object's value minus that amount, and others receiving zero) or reject it (all get zero).

            \emph{Ten markets.}
        \item Authors controlled for experimenter (ran experiences in Pittsburgh), language (translator national of relevant country), and currency (tokens as currency) effects.
            \end{tabitem}
            &   %FINDINGS
                \begin{tabenum}
            \item Theoretical equilibrium: one player receives all the wealth (in the bargaining, the player who proposes the division; in the market, the seller).
            \item Market environment: the observed market outcomes converge quickly to the perfect equilibrium, and do not deviate once reached, with no payoff-relevant differences observed between countries.
            \item Bargaining environment: the observed bargaining outcomes are significantly different from the equilibrium predictions, with substantial differences between countries.
            \item Offer and probability of acceptance: within every country these two variables were inversely related (low offers rejected more frequently than high offers), but the same does not hold across countries (higher disagreement not observed in countries with lower offers).
            \item Role of experience in between-country differences: as subjects gained experience, between-country differences in market outcomes became smaller, while in bargaining outcomes they grew larger. This supports the view that differences in bargaining behaviour are not due to differences in languages, currencies, or experimenters, but other causes.
            \item Role of culture: culture is offered as a source of observed subject-pool differences, and authors suggest laboratory experimentation as a path for future research.
                \end{tabenum}
            \bigskip
            \fconcepts{\uline{Key concepts}}%
                      {
                \begin{tabitem} 
            \item --
                \end{tabitem}
                      }
                &   %CAVEATS
                    \begin{tabenum}
                \item Much higher percentage of army veterans in Israel and Yugoslavia than US or Japan.
                \item Subjects were economics\slash business\slash psychology students, so sample is arguably contaminated.
                \item Relatively small sample sizes.
                    \end{tabenum}
            \bigskip
            \fquestions{\uline{Questions}}
                       { 
                \begin{tabitem} 
            \item What are the implications of changing the experiment from $10$ to $30$? Why would this change how subjects behave?
                \end{tabitem}
                        }   \\
    \midrule
    \end{longtblr}
\end{landscape}
\restoregeometry
\end{document}

相关内容