![当使用“longtable”包时,如何让第二页的表格标题表明它是上一页的延续?](https://linux22.com/image/272256/%E5%BD%93%E4%BD%BF%E7%94%A8%E2%80%9Clongtable%E2%80%9D%E5%8C%85%E6%97%B6%EF%BC%8C%E5%A6%82%E4%BD%95%E8%AE%A9%E7%AC%AC%E4%BA%8C%E9%A1%B5%E7%9A%84%E8%A1%A8%E6%A0%BC%E6%A0%87%E9%A2%98%E8%A1%A8%E6%98%8E%E5%AE%83%E6%98%AF%E4%B8%8A%E4%B8%80%E9%A1%B5%E7%9A%84%E5%BB%B6%E7%BB%AD%EF%BC%9F.png)
\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}