仅对某些表使用包

仅对某些表使用包

我使用tabularx环境,因为它是X列的组成部分,对于我想要生成的表格来说非常有用且必要。但是,我的一个表格比一页长,我希望它能跨页,而其他表格不会tabularx跨页。有办法吗?我找到了ltablex可以完成表格拆分工作的包,但我不希望它适用于我的所有表格。有使用的方法吗\renewenvironment

\documentclass{article} 
\usepackage{fullpage} 
\usepackage{tabularx} 
\usepackage{ltablex}    % This is the package I would like to apply to a single table
\usepackage{bigstrut} 
\begin{document} 

\begin{center}
\begin{tabularx}{\textwidth}{|l X l|}
\hline
& \textbf{HEADING} & \textbf{HEADING} \bigstrut \tabularnewline
\hline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \bigstrut[t] \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \bigstrut[t] \tabularnewline
& TEXT & \tabularnewline
\end{tabularx}
\end{center}
\end{document}

这段文字的行数足以超过整页的长度。我原本想将包ltablex放入环境中,但需要保留环境X的功能tabularx

答案1

使用方法如下ltxtable

  1. 表格放在单独的文件;环境longtable;需要时使用tabularx-style列说明符。X
  2. 使用插入表格\LTXtable{<target-width>}{<file>},设置所需的宽度并选择包含环境的适当文件longtable

需要注意的是:center环境会添加额外的垂直空间,这在某些情况下可能不是所需的。{\centering <content to be centered>}在某些情况下(通常在figure/table环境中),最好不要插入额外的垂直空间。我在这里展示了该\centering方法,但这取决于您如何将其包含在您的文档中。

\RequirePackage{filecontents}
\begin{filecontents*}{mytable.tex}
\begin{longtable}{|l X l|}
\hline
& \textbf{HEADING} & \textbf{HEADING} \bigstrut \tabularnewline
\hline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \bigstrut[t] \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \tabularnewline
& TEXT & \tabularnewline
\textbf{Number} & \textbf{WORDS} & \textbf{WORD} \bigstrut[t] \tabularnewline
& TEXT & \tabularnewline
\end{longtable}
\end{filecontents*}

\documentclass{article} 
\usepackage{fullpage} 
\usepackage{tabularx} 
\usepackage{ltxtable}    % This is the package I would like to apply to a single table
\usepackage{bigstrut} 
\begin{document} 

{\centering
  \LTXtable{\textwidth}{mytable}
}
\end{document}

在此处输入图片描述

相关内容