我想将一个大表格横跨两页。当我使用 longtable 环境时,我无法控制单元格和字体大小。当我在 longtable 启动之前更改字体大小时,字体会发生变化,但单元格保持不变。有人能帮我将下面的表格横跨两页吗?
\documentclass[12pt,letter,notitlepage]{article}
\usepackage[flushleft]{threeparttable}
\usepackage{lipsum}
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}[!htb]
\caption{\\ Example of a Very Long Table}
\label{tab:long_tale}
\centering
\footnotesize
\begin{threeparttable}
\begin{tabularx}{\linewidth}{lYYYY}
\hline \hline
& & & & \\
& (1) & (2) & (3) & (4) \\
& & & & \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
& & & & \\ \hline \hline
\end{tabularx}
\begin{tablenotes}
\fontsize{9pt}{9pt}\selectfont
\item
\textit{Notes:} \lipsum[2-4]
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案1
正如@TrevorAndrew 在评论中指出的那样,您需要从table
/ tabularx
setup 切换到longtable
setup。
顺便说一下,我想把长篇传说外部longtable
,以便允许 TeX 自由提供任何所需的分页符,而不受设置的限制longtable
。
我还会将四个数据列中的数字按小数点标记对齐。
我注意到在您的代码中,您将环境的宽度设置tabularx
为\textwidth
。我选择在以下代码中模仿此行为。如果没有必要,请告诉我。
\documentclass[12pt,letterpaper]{article}
\usepackage{lipsum,booktabs,longtable,dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}}
\begin{document}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}} l *{4}{d{2.3}} @{}}
\caption{Example of a Very Long Table} \label{tab:long_tale} \\
\toprule
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} \\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{(Table \thetable, cont'd)} \\
\toprule
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} \\
\midrule
\endhead
\bottomrule
\endlastfoot
\midrule
\multicolumn{5}{r@{}}{\raggedleft\footnotesize\em Cont'd on following page} \\
\endfoot
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\* % prevent page break
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
Example Variable & 0.49 & 0.49 & 0.49 & 0.49 \\
& (0.50) & (0.50) & (0.50) & (0.50) \\
\end{longtable}
\begingroup
\noindent\footnotesize
\textit{Notes for Table \thetable}: \lipsum[2-3]\par
\endgroup
\end{document}