longtable + multicol:如何使用每页固定位置的文本模拟 \endhead?

longtable + multicol:如何使用每页固定位置的文本模拟 \endhead?

longtable我使用的是有问题的软件包和组合multicol,但到目前为止,经过两次运行,我得到了完美的结果。只有一件事不起作用:在每页上为软件包中的每一列重复列标题multicol(我有 2 列)。没有multicol以下额外的代码就可以实现我的结果:

\multicolumn{2}{r}{{Page}}\\
\endfirsthead
\multicolumn{2}{r}{{Page}}\\
\endhead

multicol这样就行不通了(这可能是意料之中的)。作为一种解决方法,我想将文本放在Page每页顶部的固定位置来模拟结果。但我不知道如何告诉“在每页的表格开始之前执行此操作,只要表格尚未结束”。

\documentclass[a5paper,12pt]{article}
\usepackage[
    left=1.5cm,
    right=1.5cm,
    top=1.5cm,
]{geometry}
\usepackage{multicol}
\usepackage{longtable}
\usepackage{array}


\newsavebox\ltmcbox
\newenvironment{fakelongtable}
        {\setbox\ltmcbox\vbox\bgroup
        \csname @twocolumnfalse\endcsname
        \csname col@number\endcsname\csname @ne\endcsname}
        {\unskip\unpenalty\unpenalty\egroup\unvbox\ltmcbox}

\begin{document}

\clearpage
\begin{multicols}{2}
    \renewcommand*{\arraystretch}{0.85}
    \begin{fakelongtable}
        \begin{longtable}{b{4.4cm}r}
            \multicolumn{2}{r}{{Page}}\\
            \endfirsthead
            \multicolumn{2}{r}{{Page}}\\%This line and the folowing has no effect using multicol; probably expected.
            \endhead
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text Text\nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
            \hangindent=1em Text Text Text Text \nolinebreak\dotfill & 1 \\
        \end{longtable}
    \end{fakelongtable}
\end{multicols}

\end{document}

在此处输入图片描述

答案1

基本上你不能。你也许可以使用supertablextab或其他东西来手动分页。longtablemulticol都是围绕使用标准 tex 分页器输出例程的理念设计的,该例程在完成所有排版后异步分页,因此你不能在排版期间添加文本来测试它是否位于页面或列的顶部。

但是,您可以使用页面(而不是表格)标题:您可以使用自定义页面样式,但您可能希望在表格中使用固定宽度的列,这样您就知道在哪里添加文本。这也假设您总是从新页面开始表格。

相关内容