表头只生成一次并仅打印:
第 1 页,共 2 页
... 在每个页面上。有没有办法更新longtable
页眉中的页码以反映实际的当前页面,即本例中:
第 2 页,共 2 页
说到这个最小例子:
\documentclass{scrreprt}
\usepackage{longtable}
\usepackage{lastpage}
\begin{document}
\begin{longtable}{| c | c |} \hline
\textbf{Foo, bar.} & \textbf{Page~\thepage~of~\pageref{LastPage}} \\
\hline \endhead
\hline \endfoot
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
\end{longtable}
\end{document}
答案1
我强烈建议您使用supertabular
环境。这将允许您tails
以您想要的方式自定义页眉和页脚(称为)。
以下是根据您的帖子的一个简单示例:
\documentclass{scrreprt}
\usepackage{supertabular}
\usepackage{lastpage}
\begin{document}
\tablehead{\hline\textbf{Foo, bar.} & \textbf{Page~\thepage~of~\pageref{LastPage}}\\\hline }
\tablefirsthead{\hline\textbf{Foo, bar.} & \textbf{Page~\thepage~of~\pageref{LastPage}}\\\hline}
\tabletail{\hline}
\tablelasttail{\hline}
\begin{supertabular}{| c | c |}
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
\end{supertabular}
\end{document}
举几个例子:
我提供了一个新版本booktabs
只是为了更好地排版表格(在我看来),因为我删除了垂直和水平分隔符并使用了以下booktabs
规则:
\documentclass{scrreprt}
\usepackage{booktabs,supertabular}
\usepackage{lastpage}
\begin{document}
\tablehead{\toprule\textbf{Foo, bar.} & \textbf{Page~\thepage~of~\pageref{LastPage}}\\\midrule }
\tablefirsthead{\hline\textbf{Foo, bar.} & \textbf{Page~\thepage~of~\pageref{LastPage}}\\\midrule}
\tabletail{\bottomrule}
\tablelasttail{\bottomrule}
\begin{supertabular}{c c}
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
Lorem Ipsum & John Doe \\
\end{supertabular}
\end{document}
及其例子
笔记请注意,用supertabular
行话来说:
- 当然
tablefirsthead
是表格第一页的页眉, tablehead
是后续页面的标题,tabletail
是所有页面的页脚,保存最后一个,tablelasttail
是最后一个页脚