如何将页码打印到长表的重复标题上?

如何将页码打印到长表的重复标题上?

表头只生成一次并仅打印:

第 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是最后一个页脚

相关内容