I am working on tables with timed data. Data is sorted chronologically, with some multicolums when the day changes, like :
| day |
| time | event |
| time | event |
| time | event |
| time | event |
| other day |
| time | event |
If there is a page change, we "loose" the day information and have to get back one page (or several, with long same-day series) to know the day we are working on.
Thus, I would like to have a dynamic page header, with the usual static stuff (column names, etc.) and indication of the current day.
I thought that by using a macro in the header, and changing the macro value at each day change, I would get the job done. Unfortunately, it seems the header is evaluated once only, with the macro value at this time being used.
Any idea on how to « postpone » this macro evaluation ? Or to solve my problem, any other way ?
Here is a MWE of what (does not) work.
Tia,
\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}
Edit Following David Carlisle advice, I looked into supertabular, without success. There is something obvious I seem to miss. Here is a (very short) extract of the supertabular version :
\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}
I always get the «UNDEF» string in the headers.
longtable
almost completely, it typesets the header into a box and reuses that box. Instead we could change that box...longtable
again, it's been a while since I last played with its internals. Maybe I find the time tomorrow, sorry.supertabluar
instead oflongtable