Longtable 动态标题

Longtable 动态标题

我正在处理包含定时数据的表格。数据按时间顺序排序,当日期发生变化时会显示多列,例如:

|      day     |
| time | event |
| time | event |
| time | event |
| time | event |
|   other day  |
| time | event |

如果有页面更改,我们会“丢失”日期信息,并且必须返回一页(或几页,包含较长的同一天的系列)才能知道我们正在处理的日期。

因此,我想要一个动态页眉,其中包含通常的静态内容(列名等)和当前日期的指示。

我以为通过在标题中使用宏,并在每天更改时更改宏值,我就能完成工作。不幸的是,标题似乎只被评估一次,并且使用此时的宏值。

有没有关于如何“推迟”此宏评估的想法?或者还有其他方法可以解决我的问题?

这里是对什么(不)起作用的 MWE。

蒂娅,

\documentclass{scrreprt}
\usepackage{longtable}

\newcommand{\mrqtete}{UNDEFINED}
\begin{document}

\begin{longtable}{|ll|} 
\hline{}Heure& Durée\\\endfirsthead
\multicolumn{2}{l}{\hline{}Heure& Durée\\\hline\multicolumn{2}{|c|}{\mrqtete}\\\hline\endhead
\hline\multicolumn{2}{|c|}{2020-05-01}\renewcommand{\mrqtete}{2020-05-01}\\\hline
{11:23:10} &  \\
{11:26:05} &  \\
{11:39:59} &  \\
{11:41:25} &  \\
{11:53:22} &  \\
{14:23:54} &  \\
{14:24:08} &  \\
{14:33:02} &  \\
{14:33:18} &  \\
{14:36:03} &  \\
{14:44:31} & 00:01:38 \\
{14:46:29} &  \\
{14:46:44} & 00:06:30 \\
{14:54:07} &  \\
{15:27:39} & 00:00:41 \\
{15:30:03} &  \\
{15:31:27} &  \\
{15:31:37} & 00:03:17 \\
{16:52:26} &  \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:16:00} & 00:03:00 \\
{17:44:18} & 00:02:07 \\
{18:55:15} & 00:03:36 \\
{20:43:54} &  \\
{20:44:34} &  \\
{20:56:35} &  \\
{20:57:50} & 00:00:21 \\
{20:58:28} & 00:00:09 \\
{21:33:26} & 00:04:43 \\
{22:02:26} &  \\
{22:03:23} & 00:02:00 \\
{22:20:34} & 00:08:17 \\
{22:28:58} & 00:01:24 \\
{23:47:00} &  \\
\hline\multicolumn{2}{|c|}{2020-05-02}\renewcommand{\mrqtete}{2020-05-02}\\\hline
{11:45:32} &  \\
{14:49:52} &  \\
{18:35:06} & 00:00:33 \\
{19:59:38} &  \\
{20:57:02} &  \\
{21:20:02} &  \\
{21:20:46} &  \\
{21:21:34} &  \\
{21:21:50} & 00:13:05 \\
{21:36:49} & 00:01:36 \\
{22:53:31} &  \\
\hline\multicolumn{2}{|c|}{2020-05-03}\renewcommand{\mrqtete}{2020-05-03}\\\hline
{11:39:17} &  \\
{15:17:13} & 00:06:10 \\
{15:33:18} & 00:01:01 \\
{15:57:36} & 00:00:46 \\
{16:52:25} &  \\
{17:05:55} &  \\
{17:06:28} & 00:02:02 \\
{17:12:22} & 00:00:51 \\
{18:50:16} &  \\
{18:51:53} &  \\
{18:52:34} & 00:00:29 \\
{20:07:26} & 00:01:04 \\
{20:47:59} &  \\
{20:49:24} &  \\
{21:49:35} & 00:00:10 \\
{22:16:14} & 00:03:29 \\
{22:16:14} & 00:03:29 \\
{22:20:37} &  \\
\hline\multicolumn{2}{|c|}{2020-05-04}\renewcommand{\mrqtete}{2020-05-04}\\\hline
{00:02:00} &  \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:06:12} & 00:02:24 \\
{01:14:11} & 00:01:31 \\
{01:14:11} & 00:01:31 \\
{01:14:11} & 00:01:31 \\
{01:14:11} & 00:01:31 \\
{01:14:11} & 00:01:31 \\
{01:14:11} & 00:01:31 \\
{01:14:11} & 00:01:31 \\
\end{longtable}
\end{document}

编辑根据 David Carlisle 的建议,我研究了 supertabular,但没有成功。我似乎忽略了一些明显的东西。以下是 supertabular 版本的(非常简短的)摘录:

\def\mrq{UNDEF}
\tablefirsthead{\hline{}Heure& Durée\\}
\tabletail{\hline}
\tablehead{\hline{}Heure& Durée\\\multicolumn{2}{|c|}{\mrq}\\\hline}

\begin{supertabular}{|ll|}
\hline\multicolumn{2}{|c|}{2020-05-01}\\\hline\def\mrq{2020-05-01}
... table data
\hline\multicolumn{2}{|c|}{2020-05-02}\\\hline\def\mrq{2020-05-02}
\end{supertabular}

我总是在标题中看到“UNDEF”字符串。

相关内容