不使用 tabularx 创建多页表

不使用 tabularx 创建多页表

我已经创建了一个多页表。使用tabularx,我的尝试如下:

\documentclass[a4paper,preprint,aps,unsortedaddress]{revtex4}
\usepackage[top=2.5cm,bottom=2.5cm,left=3.5cm,right=2.5cm]{geometry}
\usepackage{ltablex}
\usepackage{longtable,booktabs}

\ifdefined\mc
\renewcommand{\mc}{\multicolumn}
\else
\newcommand{\mc}{\multicolumn}
\fi

\begin{document}

\begin{tabularx}{\linewidth}{lr@{--}p{1.3cm}>{\centering\arraybackslash}p{2.6cm}p{1.25cm}p{1.25cm}p{1.25cm}p{1.25cm}p{2.1cm}p{0.7cm}}
\caption{Table} \\ \hline \hline
\endfirsthead
\mc{8}{c}{\tablename\ \thetable\ -- \emph{Continued from previous page}} \\ \hline
aaa & \mc{2}{c}{bbb--ccc} & ddd & eee & fff & ggg & hhh & iii & jjj \\ \hline
\endhead
\hline \mc{8}{r}{\emph{ Continued on next page }} \\
\endfoot
\hline \hline
\endlastfoot
aaa & \mc{2}{c}{bbb--ccc} & ddd & eee & fff & ggg & hhh & iii & jjj \\
aaa & bbb & ccc & ddd & eee & fff & ggg & hhh & iii & jjj \\
aaa & bbb & ccc & ddd & eee & fff & ggg & hhh & iii & jjj \\
aaa & bbb & ccc & ddd & eee & fff & ggg & hhh & iii & jjj
\end{tabularx}

\end{document}

不包含 X 列。我想利用该{lr@{--}p{1.3cm}>{\centering\arraybackslash}p{2.6cm}p{1.25cm}p{1.25cm}p{1.25cm}p{1.25cm}p{2.1cm}p{0.7cm}}格式获取正确的多页表。您能帮我重写此代码以获取正确的表格吗?

答案1

由于表格的宽度略小于\textwidth,因此似乎不需要tabularx相关的开销。相反,只需使用longtable来排版材料即可。

在此处输入图片描述

\documentclass[a4paper,preprint,aps,
               unsortedaddress]{revtex4}
\usepackage[top=2.5cm,bottom=2.5cm,
            left=3.5cm,right=2.5cm,
            showframe]{geometry}
\usepackage{longtable,array,booktabs}
\ifdefined\mc
   \renewcommand{\mc}{\multicolumn}
\else
   \newcommand{\mc}{\multicolumn}
\fi

\begin{document} 
\begin{longtable}{ l r @{--} p{1.3cm} >{\centering}p{2.6cm} 
                   *{5}{p{1.25cm}} p{2.1cm} p{0.7cm} }               
%% headers and footers

\caption{Table} \\ 
\hline\hline
\endfirsthead

\mc{10}{c}{\tablename\ \thetable\ -- \emph{Continued from previous page}} \\ 
\hline
aaa & \mc{2}{c}{bbb--ccc} & ddd & eee & fff & ggg & hhh & iii & jjj \\
\hline
\endhead

\hline
\mc{10}{r}{\emph{Continued on next page}} \\
\endfoot

\hline\hline
\endlastfoot

%% body of table

aaa & \mc{2}{c}{bbb--ccc} & ddd & eee & fff & ggg & hhh & iii & jjj \\
aaa & bbb & ccc & ddd & eee & fff & ggg & hhh & iii & jjj \\
aaa & bbb & ccc & ddd & eee & fff & ggg & hhh & iii & jjj \\
aaa & bbb & ccc & ddd & eee & fff & ggg & hhh & iii & jjj \\

\end{longtable}
\end{document}

相关内容