1

In a longtable, I list items of several categories, including some data on them.

\documentclass{article}

\usepackage{longtable}

\begin{document}

\begin{longtable}{lll}
\hline
\textbf{These are some items} & &\\
\hline
\endhead
\hline
\endfoot
\textbf{These are items of type A} & \textbf{Size} & \textbf{Price}\\
\hline
Item 1 & 3 foot   & 3.56\\
Item 2 & 2 inches & 2.56\\
Item 3 & 5 inches & 1.50\\
\hline
\textbf{These are items of type B} & \textbf{Weight} & \textbf{Price}\\
\hline
Item A & 3 pounds & 10.50\\
Item B & 5 ounces & 6.95\\
Item C & 1 pound  & 3.00\\
\end{longtable}

\end{document}

What I would like to get is to change the running head whenever a new category is begun, so that if e.g. there is a page break between Item B and Item C, the header on the next line would read the "These are items of type B" line (so the columns are properly labeled).

Can this be done with longtable or any other "long table" package? I couldn't find information on this. (My google-fu is weak today...)

1 Answer 1

2

It's fairly automatic to do this in supertab as Irecall as the head in that case is stored as a table and re-set every time, so if you use a \mark or just a normal command that you globally define within the table, it will pick up the new definition on each page.

It could be done with longtable, and I'm fairly sure that there is some code to do it posted to comp.text.tex somewhere. longtable stores the head in a box so normally it has to be fixed throughout the table. However it wouldn't be hard to change its internals so that where it says

 \copy\LT@head

it instead says

\mysavedheadrows

where \mysavedheadrows were some table lines defined in a command before longtable starts. The man thing that would need to be ensured is that the vertical size of the rows is unchanged (longtable will get very confused if the size of teh head that is being inserted changes).

1
  • Indeed it is possible to simply use \tablehead repeatedly within a supertabular, solving my problem.
    – DevSolar
    Commented Feb 29, 2012 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .