当使用“longtable”包时,如何让第二页的表格标题表明它是上一页的延续?

当使用“longtable”包时,如何让第二页的表格标题表明它是上一页的延续?
\documentclass[letterpaper]{article}
\usepackage{longtable}              % Longtable package
\usepackage[margin=1in]{geometry}   % Margins
\usepackage{booktabs}               % Nicer horizontal lines

\begin{document}
\begin{longtable}{ l l }
\caption{Heading} \\ \toprule       % toprule, midrule, and bottomrule are the horizontal lines
Left Heading & Right Heading \\ \midrule
\endhead
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\ \bottomrule
\end{longtable}
\end{document}

上述代码产生以下结果: 第一页。 第二页。

但这是我在第二页想要的(这显然是 MS Paint 的产品,但请耐心等待) 这就是我要的:!

那么我该怎么做呢?

答案1

用于\endfirsthead第一个标题和\endhead所有其他页面。

\documentclass[letterpaper]{article}
\usepackage{longtable}              % Longtable package
\usepackage[margin=1in]{geometry}   % Margins
\usepackage{booktabs}               % Nicer horizontal lines

\begin{document}
\begin{longtable}{ l l }
\caption{Heading} \\ \toprule       % toprule, midrule, and bottomrule are the horizontal lines
Left Heading & Right Heading \\ \midrule
\endfirsthead
\caption{Heading (cont.)} \\ \toprule       % toprule, midrule, and bottomrule are the horizontal lines
Left Heading & Right Heading \\ \midrule
\endhead
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\
Left cell & Right cell \\ \bottomrule
\end{longtable}
\end{document}

结果

相关内容