使用 xltabular 制作表格时页面不会中断

使用 xltabular 制作表格时页面不会中断

我正在尝试创建一个表格,理想情况下,由于表格很长,所以可以跨不同的页面。但是,我的表格只是跨过一页,我不确定我在哪里犯了错误。

我刚开始学习 LaTeX,如能得到任何帮助我将非常感激!

表格截图

\documentclass{article}
\usepackage{multirow}
\usepackage{tabularx}

\begin{document}

\begin{table}
\centering

\makebox[\linewidth]{

\begin{tabularx}{500pt}{@{} |p{40pt}|p{50pt}|X|l|X| @{}}
\cline{1-5} 
                 Category & Solution & Explanations & Citations & Example \\ \cline{1-5} 
\multirow{3}{*}{} Pricing & Align prices with alternatives & This solution establishes price coherence between the price that the platform charges buyers with what the buyer would pay if interacting with the seller directly.
 &  & Airbnb expects that property owners will post the same price for lodging across all channels. It can monitor this through random checks or offer a low-price guarantee. \\ \cline{2-5} 
                  & Reduce commission & The intermediary could lower its percentage commission to reduce the incentive to bypass the platform. &  & Airbnb offers lower commissions for hosts who have multiple listings and large volume on the platform.\\ \cline{2-5} 
                  & Reduce price & The intermediary could lower the price that it charges buyers in order to decrease the absolute cash value of the buyer’s incentive to bypass the platform. &  & Airbnb rooms are typically less than the price of nearby hotel rooms, reducing the appeal of those substitutes. \\ \cline{1-5} 
\multirow{3}{*}{} Revenue model & Charge before match is made for lead generation & The intermediary collects user fees before performing any functions or services.
 &  & Airbnb could - but currently does not - require that buyers or sellers pay a one-time initiation fee to use the platform.\\ \cline{2-5} 
                  & Charge for advertising & The intermediary does not charge a commission to users, and therefore reduces the incentive to disintermediate. &  & Airbnb could - but currently does not - eliminate its commission and instead place advertisements inside of its site, similarly to many news sites, like CNN.com\\ \cline{2-5} 
                  & Charge a subscription & The intermediary charges for time on the platform (e.g., monthly) regardless of the number of leads, matches, or consummated transactions. &  & Airbnb could - but currently does not - require that buyers or sellers pay monthly fees to access the site. This is the approach that Match.com, a popular dating site, employs.
 \\ \cline{1-5} 
\multirow{4}{*}{} Policies & Block communication & The intermediary can use technology to disallow buyer and seller from interacting directly. &  & Airbnb uses its own closed messaging system to allow buyers and sellers to correspond with one another. This system does not allow buyers or sellers to trade contact information that would enable off-platform communication. \\ \cline{2-5}    
                  & Sanction offenders & If disintermediation is evident, the intermediary can reduce the ratings or future service access for buyers or sellers. &  & Any buyer or seller caught violating the terms of service faces the following actions: “Suspend or limit your access to or use of the Airbnb platform and/or your account; suspend or remove listings, reviews, or other content; cancel pending or confirmed bookings; or suspend or revoke any special status associated with your account.” \\ \cline{2-5} 
                  & Homogenity of service & The intermediary can ensure that each service is identical to every other in experience, quality, and price, which removes the incentive for disintermediation. &  & Airbnb sets expectations for the cleanliness of the property. It could - but currently does not - narrow its listing to, for example, only one-bedroom apartments with a kitchen and separate entrance. This would be similar to Uber’s expectation when it first launched its service in San Francisco: Drivers were encouraged to only deploy new Toyota Prius cars. \\ \cline{2-5}
                  & Homogenity of service 2 & The intermediary can ensure that each service is identical to every other in experience, quality, and price, which removes the incentive for disintermediation. &  & Airbnb sets expectations for the cleanliness of the property. It could - but currently does not - narrow its listing to, for example, only one-bedroom apartments with a kitchen and separate entrance. This would be similar to Uber’s expectation when it first launched its service in San Francisco: Drivers were encouraged to only deploy new Toyota Prius cars. \\ \cline{2-5} 
                  &  &  &  &  \\ \cline{1-5} 

\end{tabularx}

}

\caption{Sources of disintermediation} 
\label{table: sources}
\end{table}

\end{document}

答案1

  • 任何长表格(如、longtable等)都不应封装在 float 中。这可防止它们跨页显示。xltabularltablextable
  • 使用xltabular,它是longtable和的组合tabularx(为了正确显示外观,需要开发它),与其他“经典”长表类似,即、firstathed和的表。-如果您使用(相对)新包包,基于 LaTaX3 项目,足以说明应该将多少行第一表体用作表头,将多少行最后一行用作表脚。因此,我更喜欢(除其其他优秀功能外)使用此包来编写表格。\headfootlastfoottabularay
  • 上述(和其他)tabularray功能需要更长的编译时间(取决于表的复杂性)。
  • 看起来不错的表格应该比articledocumentclass 的默认文本块宽度更宽。因此,考虑使用geometry包更改默认表格布局是明智的(请参阅下面的 MWE)。

无关:
我会重新设计你的表格如下:

  • 第一列几乎为空,其中的类别将移至类别描述上方的行作为其标题,
  • 通过使用包增加\textwidth文件geometry
  • 为了更好地在单元格中归档文本,我将使用\small字体大小,
  • 对于表将使用longtblrtabularray
  • \hline从表主体中删除所有内容,
  • 对于表格其余部分的水平线,将使用booktabs包中定义的规则-

MWE (最小工作示例) 是:

\documentclass{article}
\usepackage[margin=25mm]{geometry}  % define page layout

\usepackage{microtype}              % for better spacing of words in paragraph
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}           % for "professional horizontal rules in table
\NewTableCommand\category[1][0pt]{% % for shortcut in table body code
        \SetRow{abovesep+=#1}
        \SetCell[c=4]{l, font=\small\itshape\bfseries}
\SetTblrStyle{contfoot-text}{font=\footnotesize\itshape}                            }

\begin{document}
    \begin{longtblr}[
caption = {Sources of disintermediation},
  label = {table:sources}
                    ]{colsep  = 4pt,
                      colspec = {@{} X[1.1, j, cmd=\RaggedRight] X[3,j] 
                                     X[0.9, j, cmd=\RaggedRight] X[3,j] @{}},
                      rows    = {font=\small},
                      row{1}  = {font=\small\bfseries},
                      rowsep  = 1pt,
                      rowhead = 1,
                      }
    \toprule
Solution 
    &   Explanations 
        &   Citations 
            &       Example         \\
  \midrule
% table body
\category   Pricing:
    &   &   &                       \\
Align prices with alternatives
    &   This solution establishes price coherence between the price that the platform charges buyers with what the buyer would pay if interacting with the seller directly.
        &   &   Airbnb expects that property owners will post the same price for lodging across all channels. It can monitor this through random checks or offer a low-price guarantee.
                                    \\
Reduce commission
    &   The intermediary could lower its percentage commission to reduce the incentive to bypass the platform.
        &   &   Airbnb offers lower commissions for hosts who have multiple listings and large volume on the platform.                   \\ 
Reduce price
    &   The intermediary could lower the price that it charges buyers in order to decrease the absolute cash value of the buyer’s incentive to bypass the platform.
        &   &   Airbnb rooms are typically less than the price of nearby hotel rooms, reducing the appeal of those substitutes.          \\ 
\category[5pt]   Revenue model: 
    &   &   &                       \\
Charge before match is made for lead generation
    &   The intermediary collects user fees before performing any functions or services.
        &   &   Airbnb could - but currently does not - require that buyers or sellers pay a one-time initiation fee to use the platform.    \\
Charge for advertising
    &   The intermediary does not charge a commission to users, and therefore reduces the incentive to disintermediate.
    &   &   Airbnb could - but currently does not - eliminate its commission and instead place advertisements inside of its site, similarly to many news sites, like CNN.com. 
                                    \\
Charge a subscription
    &   The intermediary charges for time on the platform (e.g., monthly) regardless of the number of leads, matches, or consummated transactions.
        &   &    Airbnb could - but currently does not - require that buyers or sellers pay monthly fees to access the site. This is the approach that Match.com, a popular dating site, employs. 
                                    \\
%    \midrule[dashed]
\category[5pt]   Policies: 
    &   &   &                       \\
Block communication
    &   The intermediary can use technology to disallow buyer and seller from interacting directly.
    &   &   Airbnb uses its own closed messaging system to allow buyers and sellers to correspond with one another. This system does not allow buyers or sellers to trade contact information that would enable off-platform communication.     \\ 
Sanction offenders
    &   If disintermediation is evident, the intermediary can reduce the ratings or future service access for buyers or sellers.
        &   &   Any buyer or seller caught violating the terms of service faces the following actions: “Suspend or limit your access to or use of the Airbnb platform and/or your account; suspend or remove listings, reviews, or other content; cancel pending or confirmed bookings; or suspend or revoke any special status associated with your account.” 
                                    \\
Homogenity of service
    &   The intermediary can ensure that each service is identical to every other in experience, quality, and price, which removes the incentive for disintermediation.
    &   & Airbnb sets expectations for the cleanliness of the property. It could - but currently does not - narrow its listing to, for example, only one-bedroom apartments with a kitchen and separate entrance. This would be similar to Uber’s expectation when it first launched its service in San Francisco: Drivers were encouraged to only deploy new Toyota Prius cars. 
                                    \\
Homogenity of service 2
    &   The intermediary can ensure that each service is identical to every other in experience, quality, and price, which removes the incentive for disintermediation.
    &   &   Airbnb sets expectations for the cleanliness of the property. It could - but currently does not - narrow its listing to, for example, only one-bedroom apartments with a kitchen and separate entrance. This would be similar to Uber’s expectation when it first launched its service in San Francisco: Drivers were encouraged to only deploy new Toyota Prius cars. 
                                    \\
    \bottomrule
\end{longtblr}

\end{document}

在此处输入图片描述

答案2

您从未使用过任何类型的长表。如果您需要xltabular,下面就是一个例子。

我做了一些更改:将标题从底部移到顶部,添加geometry以增加表格空间,为第一列和第二列添加左对齐,并添加粗体字形以区分标题和常规单元格。新的几何图形仅适用于表格。但是,如果您\usepackage[margin=1.5cm]{geometry}在序言中使用,则新布局将应用于整个文档。

就我个人而言,表格中的大多数条形图和规则都相当令人分心。我会考虑减少它们的数量并完全摆脱垂直条形图。如果你这样做,你也可以利用booktabs它的自定义规则,但该软件包不适用于垂直条形图。

在此处输入图片描述

\documentclass{article}
\usepackage[pass]{geometry}
\usepackage{ragged2e}
\usepackage{multirow}
\usepackage{xltabular}

\begin{document}
\begingroup
\newgeometry{margin=1.5cm}
\renewcommand*\arraystretch{1.45}
\setlength\extrarowheight{-1pt}
\begin{xltabular}{\linewidth}{@{} |>{\RaggedRight}l|>{\RaggedRight}p{50pt}|X|l|X| @{}}
  \caption{Sources of disintermediation\label{table: sources}} \\
  \noalign{\hrule height 0.8pt}
  \rule[-6pt]{0pt}{18pt}\textbf{Category}
  & \textbf{Solution}
  & \textbf{Explanations}
  & \textbf{Citations}
  & \textbf{Example} \\
  \noalign{\hrule height 0.5pt} \endhead
  \noalign{\noindent\smash{\vrule height 0.8pt width \linewidth}} \endfoot 
  \multirow{3}{*}{} Pricing
  & Align prices with alternatives
  & This solution establishes price coherence between the price that the platform charges buyers with what the buyer would pay if interacting with the seller directly.
  & & Airbnb expects that property owners will post the same price for lodging across all channels. It can monitor this through random checks or offer a low-price guarantee. \\ \cline{2-5}
  & Reduce commission
  & The intermediary could lower its percentage commission to reduce the incentive to bypass the platform.
  & & Airbnb offers lower commissions for hosts who have multiple listings and large volume on the platform.\\ \cline{2-5}
  & Reduce price
  & The intermediary could lower the price that it charges buyers in order to decrease the absolute cash value of the buyer’s incentive to bypass the platform.
  & & Airbnb rooms are typically less than the price of nearby hotel rooms, reducing the appeal of those substitutes. \\ \hline
  \multirow{3}{*}{} Revenue model
  & Charge before match is made for lead generation
  & The intermediary collects user fees before performing any functions or services.
  & & Airbnb could - but currently does not - require that buyers or sellers pay a one-time initiation fee to use the platform.\\ \cline{2-5} 
  & Charge for advertising
  & The intermediary does not charge a commission to users, and therefore reduces the incentive to disintermediate.
  & & Airbnb could - but currently does not - eliminate its commission and instead place advertisements inside of its site, similarly to many news sites, like CNN.com \\ \cline{2-5} 
  & Charge a subscription
  & The intermediary charges for time on the platform (e.g., monthly) regardless of the number of leads, matches, or consummated transactions.
  & & Airbnb could - but currently does not - require that buyers or sellers pay monthly fees to access the site. This is the approach that Match.com, a popular dating site, employs. \\ \hline
  \multirow{4}{*}{} Policies
  & Block communication
  & The intermediary can use technology to disallow buyer and seller from interacting directly.
  & & Airbnb uses its own closed messaging system to allow buyers and sellers to correspond with one another. This system does not allow buyers or sellers to trade contact information that would enable off-platform communication. \\ \cline{2-5}    
  & Sanction offenders
  & If disintermediation is evident, the intermediary can reduce the ratings or future service access for buyers or sellers.
  & & Any buyer or seller caught violating the terms of service faces the following actions: “Suspend or limit your access to or use of the Airbnb platform and/or your account; suspend or remove listings, reviews, or other content; cancel pending or confirmed bookings; or suspend or revoke any special status associated with your account.” \\ \cline{2-5} 
  & Homogenity of service
  & The intermediary can ensure that each service is identical to every other in experience, quality, and price, which removes the incentive for disintermediation.
  & & Airbnb sets expectations for the cleanliness of the property. It could - but currently does not - narrow its listing to, for example, only one-bedroom apartments with a kitchen and separate entrance. This would be similar to Uber’s expectation when it first launched its service in San Francisco: Drivers were encouraged to only deploy new Toyota Prius cars. \\ \cline{2-5}
  & Homogenity of service 2
  & The intermediary can ensure that each service is identical to every other in experience, quality, and price, which removes the incentive for disintermediation.
  & & Airbnb sets expectations for the cleanliness of the property. It could - but currently does not - narrow its listing to, for example, only one-bedroom apartments with a kitchen and separate entrance. This would be similar to Uber’s expectation when it first launched its service in San Francisco: Drivers were encouraged to only deploy new Toyota Prius cars. \\
\end{xltabular}
\restoregeometry
\endgroup
\end{document}

相关内容