# How to get \marks with longtable?

I'm using longtable and trying to use \marks. So far I've got no luck.

MWE:

\documentclass[a5paper,pagesize]{scrartcl}
\usepackage{longtable}
\usepackage{scrpage2}
\pagestyle{scrplain}
\newcommand*{\tablerow}[1]{%
#1\mark{#1}\tabularnewline[2cm]}
\begin{document}
\begin{longtable}{p{.9\textwidth}}
\tablerow{1}\tablerow{2}\tablerow{3}\tablerow{4}\tablerow{5}
\tablerow{6}\tablerow{7}\tablerow{8}\tablerow{9}\tablerow{10}
\tablerow{11}\tablerow{12}\tablerow{13}\tablerow{14}\tablerow{15}
\end{longtable}
\end{document}


In the result \firstmark and \botmark are always empty. Am I doing something wrong or is this a bug/limitation of longtable/LaTeX?

-

Clearly it could only be a limitation in longtable as my packages don't have bugs but you might want to read

However apart from that the marks in your example will have no effect as they only ever have effect in tex if they are in the main vertical list (or can migrate to the main vertical list from horizontal mode). Marks in \parbox and friends do nothing unless the box is eventually unboxed.
Your marks are in a p columns which is a \parbox essentially. They need to be in lcr columns.
O.K. And I need to use \firstmark. But why is \firstmark=\botmark on the last page? –  Martin Schröder Sep 7 '12 at 9:36
Latex's output routine has \let\firstmark\botmark you are not supposed to use bare marks always marks with two fields accessed by leftmark and rightmark (not that I always follow the rules either) –  David Carlisle Sep 7 '12 at 9:48
So how do I get the first and last element of a page with LaTeXs macros? Because even if I use \markboth and \rightmark and \leftmark in the example, on the last page it's still \rightmark==\leftmark. –  Martin Schröder Sep 7 '12 at 9:54