I have a very long longtable (>100 pages) with 4 columns which represents an index into some literary text. The index data is programmatically produced and I have removed the first (index element) for all but its first occurance. There are cases, where for one index element follow many lines and there are therefore pages where there is no index element shown at all.
The page should look like:
Header A-Entry
value1 value2 .. which is the continuation of A-entry
value3 value4
... many more A-entry lines till a new index entry
B-entry value5 value6
value7 value8
C-entry ...
I see three approaches for a solution:
- Show the current (i.e. last seen) index entry in the page header.
- Remove the index in the first column when it is repeated within a page by a latex function.
- Put the current (i.e. last seen) index in the header of the longtable.
I have seen in this question a solution using struts but have not found any other documentation. Is this a path to a solution of my problem?
My current solution (following the advice received) is:
\documentclass{article}
\usepackage[german]{babel}
\usepackage{booktabs,array,microtype, longtable}
\usepackage{alltt} % to use input with commands
\usepackage{fontspec}
\newfontfamily{\tablefont}{ebgaramond}
\usepackage{lmodern} % to avoid scalable font error
\usepackage[automark,headsepline,plainheadsepline]{scrlayer-scrpage}
\begin{document}
\newcommand{\dohang}{\hangindent1em\hangafter1 }
\begin{scriptsize}\tablefont
\mark{ AAA3mal}
\begin{longtable}{@{}
l
>{\everypar{\dohang}\dohang\raggedright\arraybackslash}p{18mm}
>{\everypar{\dohang}\dohang\raggedright\arraybackslash}p{55mm}
>{\everypar{\dohang}\dohang\raggedright\arraybackslash}p{26mm}
p{9mm}}
{} & Lemma & Gedichtzeile & Gedichttitel & Index \\\\
\endfirsthead
\markboth{Trankst}{Trankst}&Trankst & Trankst du begierig, durst'ger Greis! & Am Sarg eines & 7:1-12\\
\markboth{traulich}{traulich}&traulich & Wo, traulich sich dran schmiegend, es & Im Schnee & 1:1-13\\
\markboth{träumend}{träumend}&träumend & Welche träumend drinnen schliefen & Himmelsleiter & 5:2-1\\
\markboth{Türe}{Türe}&Türe & Hockt vor der Tür und flickt die alten Schuh. & Wie glänzt der helle &
\end{longtable}
\end{scriptsize}
\end{document}
The solution works because I have (programmatically) produced the data lines to form the index and added to each line a \markboth{XXX}{XXX}& or just & when no entry XXX starts. Second, I added an empty column with type "l" with header "{}", because a "p" column does not trigger the \mark command. It works but would not work with the simpler \mark.
\marks to affect the page header but if you want to change the table\endheadlines to show the last index entry then see https://tex.stackexchange.com/questions/263597/change-endhead-in-the-middle-of-a-longtable (either answer may be suitable) – David Carlisle Jun 08 '19 at 16:35\markboth{aa}{bb}or\markright{aaa}not the primitive\markin latex – David Carlisle Jun 11 '19 at 13:47\markbothrather than\markrightor ... – David Carlisle Jun 11 '19 at 16:41